Skip to content Skip to sidebar Skip to footer

Ajax Problem - No Response Text In Firefox, But Ok In Ie

I am making a simple AJAX call to an external site. It works ok in IE, but in Firefox, not response text is returned. I think it might have something to do with the response being

Solution 1:

Is your page hosted at http://drc.edeliver.com.au also? If not, then you can't make an XMLHttpRequest to that URL. It's a violation of basic browser security which, for your IE tests, are probably suppressed by explicit browser configuration.

edit — I think IE lets the "local security zone" (or whatever they call it) get away with stuff that is not allowed for "Internet" zone pages.

Solution 2:

You may want to try using a relative URL in urlString, to avoid problems with the Same Origin Policy.


UPDATE: Further to the comments, if JSONP is not an option, you could also set up a simple reverse proxy to get around the same origin policy. You could use mod_proxy if you are using Apache. This would allow you to use relative paths in your AJAX request, while the HTTP server would be acting as a proxy to any "remote" location.

The fundamental configuration directive to set up a reverse proxy in mod_proxy is the ProxyPass. You would typically use it as follows:

ProxyPass     /remote/     http://drc.edeliver.com.au/

In this case, the browser would be able to request /remote/ratecalc.asp but the server would serve this by acting as a proxy to http://drc.edeliver.com.au/ratecalc.asp, while it appears to the browser as if it is being served from the same origin.

Solution 3:

Yes, the chunked response (COMET streaming) may be the problem:

http://blogs.msdn.com/b/ieinternals/archive/2010/04/06/comet-streaming-in-internet-explorer-with-xmlhttprequest-and-xdomainrequest.aspx

As streaming is still associated with many problems (e.g. when using proxies), my current recommendation would be to use long polling instead (closing the response for each chunk, and issuing a new request immediately). It's an unfortunate situation - I'd prefer to use streaming, too.

Edit

We found out, that this isn't actually the problem here!

Solution 4:

I believe the problem is a simple case of cross-domain security.

I am trying to make an AJAX call from a local static HTML page to an external URL.

IE allows me to do this. Firefox does not allow me to do this.

Firefox does not provide an error message (like it does with a cross-domain iFrame DOM access). The response text is simply empty.

Thanks everyone for your help. Sorry to post such a dozey question.

Solution 5:

For cross domain request, have a look at this article.

Probably you will need to enable following headers for it to work in FF/Chrome:

Access-Control-Allow-Origin: *Access-Control-Allow-Methods: POST, GET, OPTIONS

Post a Comment for "Ajax Problem - No Response Text In Firefox, But Ok In Ie"