ajax 呼び出しによって返される json は次のとおりです。
{
"StumbleUpon": 0,
"Reddit": 0,
"Facebook": {
"commentsbox_count": 0,
"click_count": 0,
"total_count": 0,
"comment_count": 0,
"like_count": 0,
"share_count": 0
},
"Delicious": 0,
"GooglePlusOne": 1,
"Buzz": 0,
"Twitter": 1,
"Diggs": 0,
"Pinterest": 0,
"LinkedIn": 1
}
jqueryで処理しようとしているのですが、なぜか理解できず、 Facebook.total_count が定義されていません。上記の json を受信したことがコンソールに表示されるので、別の方法を期待します。さらに、他のすべて (data.Twitter など) が機能します。エラーが発生したコールバック関数を次に示します。私は何を間違っていますか?
function(data){
console.log(data);
//this line throws the error
var fb = data.Facebook;
var total = parseInt(data.Twitter + parseInt(fb.total_count) + data.GooglePlusOne + data.Pinterest + data.LinkedIn);
// rest of code.
}
jsFiddleのコードを参照してください。