我试图使用jquery在json中获取facebook提要....
这是我试图获取数据的脚本
$(function () {
$.ajax({
url: 'http://www.facebook.com/feeds/page.php?id=237173582992285&format=JSON',
type: 'get',
dataType: "jsonp",
success: function (data) {
alert("data successfully came ");
}, error: function (data) {
alert("fail to get the data");
}
});
});
我在mozila中有跟踪firefox.in控制台数据以json格式返回...
数据在成功方法中没有约束力.. 数据以错误方式绑定..
请查看上面附带的快照
答案 0 :(得分:1)
该URL不允许JSONP类型请求,因为它不会在回调中包装JSON。但是,您可以通过Googles feeds API代理请求,这可以执行跨源资源加载。
<script>
function jsapi_loaded(){
google.load("feeds", "1");
function initialize() {
var feed = new google.feeds.Feed(
"https://www.facebook.com/feeds/page.php?format=rss20&id=237173582992285"
);
feed.setNumEntries(10);
feed.load(function(result) {
if (!result.error) {
console.log(result);
}
});
}
google.setOnLoadCallback(initialize);
}
</script>
<script src="https://www.google.com/jsapi?callback=jsapi_loaded" async></script>