您好,我有以下JSON對象:如何訪問JSON對象中的數組?
[
{
"comments":[
{
"created_at":"2011-02-09T14:42:42-08:00",
"thumb":"xxxxxxx",
"level":1,"id":214,
"user_id":41,
"parent_id":213,
"content":"<p>xxxxxx</p>",
"full_name":"xx K"
},
{
"created_at":"2011-02-09T14:41:23-08:00",
"thumb":"xxxxxxxxxxxxx",
"level":0,
"id":213,
"user_id":19,
"parent_id":null,
"content":"<p>this is another test</p>",
"full_name":"asd asd asd asd asd"
}
],
"eee1":"asdadsdas",
"eee2":"bbbbb"
}
]
這是從$.ajax
請求到來,成功,我有....
success: function (dataJS) {
console.log(dataJS);
console.log(dataJS[eee1]);
console.log(dataJS.comments);
}
問題是我無法訪問即使dataJS在控制檯中正確顯示,也是如此。想法?
感謝
console.log(dataJS.comments [0]); ? – orolo 2011-03-02 21:21:10
您是否檢查過響應頭的內容類型確實是application/json? – jimmystormig 2011-03-02 21:22:13