【发布时间】:2015-11-25 02:26:57
【问题描述】:
这是我的第一次 ajax 体验。我已经使用 ajax 成功地从服务器获得了 GET 响应。但我面临从 JSON 中检索值的问题。
我的 ajax 调用:
url: "ur",
type: "GET",
cache: false,
dataType:"json",
contentType: "application/json",
success: function(res) {
console.log(res);
}
来自服务器的 JSON 响应:
{
"message": [
{
"files": "SS",
"messageBody": "gOOD",
"messageID": 1,
"messageTitle": "THTH",
"photos": "DD",
"userID": 2,
"videos": "FF"
},
{
"files": "",
"messageBody": "bla bala blaa",
"messageID": 2,
"messageTitle": "another",
"photos": "",
"userID": 3,
"videos": ""
},
{
"files": "The Cock files",
"messageBody": "New message 11 Body",
"messageID": 3,
"messageTitle": "New message 11 Title",
"photos": "The Cock photos",
"userID": 3,
"videos": "The Cock videos"
}
]
}
我可以在控制台中打印 JSON 对象。但问题是从 JSON 中检索内容。我尝试了多种方法来从 JSON 对象中检索值。任何帮助都将是可观的。
[注意:我是 Ajax 的新手。请不要标记为重复。]
【问题讨论】:
标签: javascript jquery json ajax