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 に追加のライブラリを使用していません。
編集:
「jsonp」ではなく「json」を dataType として使用して ajax 呼び出しを実行しようとすると、サーバーは空の文字列で応答します。