Sunday, July 05, 2009

Not the same origin

By the way, Firefox 3.5 allows you to make XMLHttpRequests cross domain (in other words code loaded from some domain can make XHR requests to domain Mozilla's spec suggests a special HTTP header for that:

Access-Control-Allow-Origin: *

with this header your server informs client that cross domain request is Ok from any domain. Instead of * you can use there a name of domain allowed to perform cross domain requests.

And here is Java servlets filter from JSOS lets you add such a header to your site so cross domain requests could be allowed for existing web applications - Cross domain Ajax filter.


Unknown said...

Hi there,

I came across your cross domain ajax site and tried to get it running. I didn't succeed. Here is my minimal example:


When I call this page ... nicely reads this one.

But when I download local.html and run it on the Desktop or on my blog's domain the request returns an empty string and XmlHttpRequest.status = 0.

The crossdomainajaxflt.jar is located in WEB-INF/lib and my web app says:




What am I doing wrong? Any idea?


Anonymous said...

And what was saying in your web app?
It looks like there is some error

Unknown said...

oh sorry, the commenting function just removed the < > braces. Another try - web.xml:


I had some typos first but this lead to a GAE server error 500. What I post here is currently running (as you can call the URLs posted before). But it just refuses ajax calls from another domain/my local file system.

Thanks for your time

Coldbeans software said...

>braces. Another try - web.xml:
it is a description for the filter. Did you add mapping also?

Unknown said...

Nope - just wanted to create a minimal example. Is a mapping required? Because I understood: "By default filter allows cross domain requests from any domain". Maybe a complete example of the web.xml would make it more comprehensible then.

Do you have a running instance that I could AJAX-request from my server? Just to make sure the problem is not in my scripts.

Coldbeans software said...

>Is a mapping required?
Yes. Mapping describes what request will be serviced by the filter. Without mapping filter simply does not work