‘jQuery.getJSON’无法在Internet Explorer 8中运行
我正在使用jQuery.getJSON
来获取Facebook好友列表,但我没有得到它。 它在Firefox和Chrome中运行良好,但在Internet Explorer 8中无效。
jQuery.getJSON("https://graph.facebook.com/me/friends?access_token="+aToken, function(data) { alert(data); } );
在做了一些研究后,我也尝试了这段代码:
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); });
在你的代码中尝试这个hack(根据下面的评论)
jQuery.support.cors = true;
Internet Explorer 8不支持jQuery正在使用的XMLHttpRequest对象中的CORS。 Internet Explorer 8使用XDomainRequest对象 ,默认情况下jQuery不支持该对象 。
我在这里使用Jason Moon脚本完全解决了这个问题
希望能帮助到你。