這是我在Jsonlint驗證的本地Json。爲什麼我的jquery json each()循環返回undefined?
{
"messages": {
"count": "0",
"items": [
{
"MessageID": "1",
"Starred": 0,
"BodyPrev": "You wouldn't believe what has just happenedYou wouldn't believe what has ",
"FromUserID": "1",
"FromName": "Daisy Purdye",
"FromUN": "daisypurdye",
"Subject": "Yeayeah",
"Body": "You wouldn't believe what has just happenedYou wouldn't believe what has just happenedYou wouldn't believe what has just happenedYou wouldn't believe what has just happenedYou wouldn't believe what has just happenedYou wouldn't believe what has just happened",
"Ctime": "10/4/2012",
"isRead": "1"
},
{
"MessageID": "2",
"Starred": 1,
"BodyPrev": "Whatever",
"FromUserID": "1",
"FromName": "Daisy Purdye",
"FromUN": "daisypurdye",
"Subject": "Not true mate",
"Body": "Whatever",
"Ctime": "5/3/2012",
"isRead": "1"
}
]
}
}
,這裏是jQuery的打印出來的消息...
<script>
$.getJSON("/json/messages.json",function(result){
$.each(result, function(i, messages){
console.log(messages.items.Subject)
});
});
</script>
它只是返回undefined。
優秀的存在, 謝謝。這是我疲憊的心靈可能整天看着它,仍然沒有看到明顯的那些問題之一:D這是非常有道理的。當我被允許時,我會在幾分鐘內接受答案。 –