$ .getJSON在IE中不起作用 [英] $.getJSON not workin in IE

查看:128
本文介绍了$ .getJSON在IE中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码从JSON中获取数据。

I am using following code to grab data from JSON.

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

        $.each(data.issue.page, function(i,item) {
            imagesJSON[i] = item["@attributes"];
        });

       alert(imagesJSON.length);
    });
 });

它适用于Mozilla,Chrome和其他浏览器,但不适用于IE。(不在任何版本中)。

It works in Mozilla, chrome and other browser but not in IE.(Not in any Version).

推荐答案

$。getJSON 倾向于缓存结果在IE中。请改用 $。ajax

$.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); }
});

确保你有 cache:false

更新:

它似乎是主机上的配置问题,其中OP实际使用了请求URL。使用IE Web浏览器直接访问URL会导致主机中止。除了向主持人报告问题之外,您所做的不过很多,例如向主持人的网站管理员发送电子邮件。

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.

这篇关于$ .getJSON在IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆