我找回一些JSON,并需要将其显示在我的页面上,但它似乎不会显示!为什么我无法处理JSON响应?
有人可以请看看,看看你是否能看到我要去哪里错了?
代码:
$.ajax({ type: "GET",
url: "URL GOES HERE - Cant give for obvious reasons :)",
dataType: "jsonp",
success: function (response) {
var result = response.d;
$.each(result, function (index, res) {
$('#questions').val(res.q);
});
},
error: function (msg) {
}
});
JSON:
{
"d": [
{
"id": "1002 ",
"q": "What region is Auchentoshan whisky made in",
"a1": "Highlands",
"a2": "Speyside",
"a3": "Lowlands"
},
{
"id": "1042 ",
"q": "Chase’s award winning vodka is made from...",
"a1": "Grapes",
"a2": "Rye",
"a3": "Potatoes"
}
]
}
所以'的console.log(响应)'在成功处理程序提供了什么? – VisioN 2012-07-20 16:18:43
您网页上的哪些元素具有“问题”ID? – MrOBrian 2012-07-20 16:19:19
你为什么使用'datatype:“jsonp”'而不是'“json”'? – jessegavin 2012-07-20 16:19:34