我找回一些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