0
我想獲得使用FB API的評論。我找回的json是正確的,但我無法循環瀏覽json。Facebook的評論,通過JSON循環
這裏是我的JS: -
$(document).ready(function() {
$('.showcomments a').click(function() {
var id = $(this).attr('id').split('-');
id = id[1];
$.ajax({
url: "https://graph.facebook.com/"+id+"/comments?access_token=foobar",
type: 'GET',
datatype: 'json',
success: function(comments) {
$.each(comments.data, function(i, comment){
alert('<h3>'+comment.from.name+'</h3><p>'+comment.message+'</p>');
});
}
});
});
});
我認爲這個問題是與comments.data
螢火給出如下: -
a is undefined
[Break On This Error] (function(a,b){function cv(a){return f...ndexOf(".")>=0&&(i=h.split("."),h=i.
乾杯任何幫助
你看到了什麼,當你把'的console.log(評論)'的'success'回調的開始? – Blazemonger
{「data」:[{「id」:「foobar」,「from」:{「name」:「foobar」,「id」:「foobar」},「message」:「foobar」,「created_time」: 「2011-11-08T14:31:22 + 0000」}],「paging」:{「next」:「https://graph.facebook.com/foobar/comments?access_token=foobar&limit=25&offset=25」}} – pjknight
http://jsfiddle.net/mblase75/bFY6y/ - 似乎在這裏工作得很好。 – Blazemonger