$.getJSON not working in Internet Explorer

后端 未结 2 1993
予麋鹿
予麋鹿 2020-12-07 01:04

I am using following code to grab data from JSON.

 $(document).ready(function()
 {
   $.getJSON(\"http://www.example.com/data.php?id=113&out=json\", fun         


        
2条回答
  •  孤城傲影
    2020-12-07 02:02

    $.getJSON has a tendency to cache results in IE. Use $.ajax instead.

    The related call should be something like this in your case:

    // Not really sure if you've forgot to var 
    var imagesJSON = [];
    
    $.ajax({
      url: "www.example.com/data.php?id=113&out=json",
      cache: false,
      dataType: "json",
      success: function(data) {
        $.each(data.issue.page, function(i,item) {
            imagesJSON[i] = item["@attributes"];
        });
    
        alert(imagesJSON.length);
      },
      error: function (request, status, error) { alert(status + ", " + error); }
    });
    

    Make sure you have cache: false.


    UPDATE:

    It appears to be a configuration issue at the host with the request url that the OP actually uses. Going to the url directly with IE web browser results in an abort from the host. You can't do much than to report the issue to the host, like an email to the webmaster of the host.

提交回复
热议问题