JQuery Ajax request not working on iPhone device browser

前端 未结 5 1733
傲寒
傲寒 2021-02-10 02:07

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

相关标签:
5条回答
  • 2021-02-10 02:46

    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 });
    
    0 讨论(0)
  • 2021-02-10 02:54

    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.

    0 讨论(0)
  • 2021-02-10 02:57

    The answer for me was moving the script tag into the head tag.

    0 讨论(0)
  • 2021-02-10 03:03

    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"

    0 讨论(0)
  • 2021-02-10 03:08

    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.

    0 讨论(0)
提交回复
热议问题