Nat*_*Sri 3 jquery facebook getjson
我正在jQuery.getJSON
用来获取Facebook好友列表,但我没有得到它.它在Firefox和Chrome中运行良好,但在Internet Explorer 8中无效.
jQuery.getJSON("https://graph.facebook.com/me/friends?access_token="+aToken,
function(data) {
alert(data);
}
);
Run Code Online (Sandbox Code Playgroud)
在做了一点研究后,我也尝试了这段代码:
jQuery.ajax({
url:"https://graph.facebook.com/me/friends?access_token="+aToken,
type: 'json',
success: function(json) {
alert(json);
}
});
Run Code Online (Sandbox Code Playgroud)
Internet Explorer 8不支持jQuery正在使用的XMLHttpRequest对象中的CORS .Internet Explorer 8使用XDomainRequest对象,默认情况下jQuery不支持该对象.
试试这个来处理错误:
jQuery.getJSON("https://graph.facebook.com/me/friends?access_token=" + aToken,
function(data) {
alert(data);
}
)
.error(function(jqXHR, textStatus, errorThrown) { alert(errorThrown); });
Run Code Online (Sandbox Code Playgroud)
在你的代码中尝试这个hack(根据下面的评论)
jQuery.support.cors = true;
Run Code Online (Sandbox Code Playgroud)