sam*_*ami 3 ajax jquery json yql
我想知道如何使用YQL获取JSON数据.
这是我的JSON URL:
https://www.facebook.com/feeds/page.php?id=397319800348866&format=json
Run Code Online (Sandbox Code Playgroud)
下面是一个使用jQuery的快速示例,它可能会帮助你
$(function () {
$.ajax({
url: "http://query.yahooapis.com/v1/public/yql",
dataType: "jsonp",
success: function (data) {
console.log(data.query.results.json);
$.each(data.query.results.json.entries, function (i, v) {
//console.log(data.query.results.json.entries[i]);
$('#entries').append(data.query.results.json.entries[i].title + '<br />');
});
}, data: {
q: 'select * from json where url="https://www.facebook.com/feeds/page.php?id=397319800348866&format=json"',
format: "json"
}
});
});
Run Code Online (Sandbox Code Playgroud)
在使用上面的url的console.log中,我能够得到以下结果:
entries: Array[29]
icon: "http://www.facebook.com/favicon.ico"
link: "http://www.facebook.com/"
self: "https://www.facebook.com/feeds/page.php?id=397319800348866&format=json"
title: "Doers Inc's Facebook Wall"
updated: "2012-12-19T01:08:44-08:00"
Run Code Online (Sandbox Code Playgroud)
工作实例供参考:http://jsfiddle.net/DtNxb/1/
| 归档时间: |
|
| 查看次数: |
1533 次 |
| 最近记录: |