We are in the process of developing an iPhone web app using extensive jquery AJAX calls to extract data from an XML web service. When developing and testing on my Mac on Safari
I had the same problem writing an AJAX chat for a website. The problem is the cache. Add this line of code and the problem is solved.
$.ajaxSetup({ cache: false });
I ran into the same problem.
Check the url: parameter in the object you send to the jQuery.ajax function. Shorten it from "http://the/full/url" to "/just/the/relative/to/root/part"
To me, it seems like a Safari Mobile bug.
The answer for me was moving the script tag into the head tag.
Ok, I think we have solved this, although it still leaves me perplexed.
If we do a 'dummy' XMLHttpRequest straight after the onReady() section in our code, then it seems to 'unblock' any following requests.
http = new XMLHttpRequest();
http.open("GET", "/getdata/dummy.xml);
http.onreadystatechange=function() {
if(http.readyState == 4) {
// alert(http.responseText);
}
}
http.send(null);
If I comment out this code block, then following perfectly valid XML requests fail. Once again, this is only on the device, as Safari and the emulator will work without this code block in place.
PS: dummy.xml simply returns "nothing"
You can enable the javascript console in Mobile Safari. See the instructions here. It's basically Settings->Safari->Developer->Debug Console. This works on the emulator, and the actual device.