我正在使用javascript api来获取Facebook评论。
我得到以下json结果,但是如何解析它们以在我的页面上使用?
{
"id": "1234567891_2823098717038_3160191",
"from": {
"name": "User",
"id": "1234567891"
},
"message": "comment only...",
"can_remove": true,
"created_time": "2012-05-05T07:43:11+0000"
},
{
"id": "1234567891_2823098717038_3160281",
"from": {
"name": "User",
"id": "1234567891"
},
"message": "just another comment...",
"can_remove": true,
"created_time": "2012-05-05T08:14:17+0000"
},
{
"id": "1234567891_2823098717038_3160336",
"from": {
"name": "user2",
"id": "56265654845454"
},
"message": "congratz dear :)",
"can_remove": true,
"created_time": "2012-05-05T08:29:05+0000"
}
],
"paging": {
"next": "http://link.dddd"
}
}
我如何循环浏览并显示内容?
jQuery解决方案是可以接受的。
谢谢。
答案 0 :(得分:1)
使用JQuery.parseJSON
:http://api.jquery.com/jQuery.parseJSON/
答案 1 :(得分:0)
assoc_data = jQuery.param(response); //响应是你的json
$。AJAX({ 类型:“POST”, url:“submit_fb_data.php”, data:assoc_data, 成功:功能(数据){
//etc
}
});