'jQuery.getJSON'在Internet Explorer 8中无法使用 [英] 'jQuery.getJSON' not working in Internet Explorer 8

查看:126
本文介绍了'jQuery.getJSON'在Internet Explorer 8中无法使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery.getJSON 来获取Facebook的朋友列表,但我没有得到它。它在Firefox和Chrome中完美无缺,但在Internet Explorer 8中无法使用。

I am using jQuery.getJSON to fetch the Facebook friends list, but I am not getting it. It works perfectly in Firefox and Chrome, but it is not working in Internet Explorer 8.

jQuery.getJSON("https://graph.facebook.com/me/friends?access_token="+aToken,
    function(data) {
        alert(data);
    }
);

此外,在做了一些更多的研究后,我也尝试了这个代码:

Also after doing a little more research I tried with this code also:

jQuery.ajax({
    url:"https://graph.facebook.com/me/friends?access_token="+aToken,
    type: 'json',
    success: function(json) {
        alert(json);
    }
});


推荐答案

尝试这样来处理错误:

jQuery.getJSON("https://graph.facebook.com/me/friends?access_token=" + aToken, 
    function(data) {
        alert(data);
    }
)
.error(function(jqXHR, textStatus, errorThrown) { alert(errorThrown); });

在你的代码中尝试这个黑客(根据下面的评论)

And try this hack in your code (as per comment below)

jQuery.support.cors = true;

这篇关于'jQuery.getJSON'在Internet Explorer 8中无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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