The following piece of logic used to work with both jquery 1.4.4 and 1.7.1 on all mobile devices that we\'re supporting:
$.ajax({
url: \'http://www.example
The link that I provided in the question is actually pointing to the solution. Some of my ajax requests are used to fetch URL's of PDFs which are streamed using
Content-Disposition: attachment; filename="somename.pdf"
Apparently, that causes major issues in iOS 5.0's Safari, breaking the XMLHttpRequest
object (it is not related with jquery). Crazy. Here's the link again:
http://spin.atomicobject.com/2012/01/20/mobile-safari-on-ios-5-1-unexpectedly-making-cross-origin-resource-sharing-requests/
Thank you for the investigation. I am having the same problem. After receiving a file as 'attachment' Mobile Safari sends OPTIONS request when calling:
$.ajax('/url')
BUT, if I run the following code from the same file, it generates a valid GET request:
http = new XMLHttpRequest()
http.open("GET", "/url")
http.send()
Why jQuery is not working but XMLHttpRequest works here?
The reason for the error is the same origin policy. It only allows you to do XMLHTTPRequests to your own domain. See if you can use JSON instead.
References and recommended resources;
https://stackoverflow.com/a/1109261/896341
http://api.jquery.com/jQuery.getJSON/
http://www.w3.org/Security/wiki/Same_Origin_Policy
https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript