我正在使用 jQuery 版本 1.5.1 来执行以下的 Ajax 调用:
$.ajax({
dataType: 'jsonp',
data: { api_key : apiKey },
url: "http://de.dawanda.com/api/v1/" + resource + ".json",
success: function(data) { console.log(data); },
error: function(jqXHR, textStatus, errorThrown) { console.log(errorThrown); console.log(textStatus); }
});
服务器会用一个有效的JSON对象作为响应返回:
{
"response": {
"type":"category",
"entries":1,
"params":{
"format":"json",
"api_key":"c9f11509529b219766a3d301d9c988ae9f6f67fb",
"id":"406",
"callback":"jQuery15109935275333671539_1300495251986",
"_":"1300495252693"
},
"pages":1,
"result":{
"category":{
"product_count":0,
"id":406,
"restful_path":"/categories/406",
"parent_id":null,
"name":"Oberteile"
}
}
}
}
但成功回调从未被调用,相反,错误回调会产生以下输出:
jQuery15109935275333671539_1300495251986 was not called
parsererror
这是为什么呢?
我在使用jQuery时没有使用其他额外的库。
编辑:
如果我尝试使用"dataTypes"中的"json"来进行ajax调用,服务器会以空字符串响应。