我正在尝试调用跨域 url。它的响应文本如下。它是有效的 json 响应。
[{"LANG_CODE":"UK_EN","COU_ISO_CODE":"BGR"},
{"LANG_CODE":"UK_EN","COU_ISO_CODE":"HUN"},
{"LANG_CODE":"UK_EN","COU_ISO_CODE":"PRT"},
{"LANG_CODE":"UK_EN","COU_ISO_CODE":"UGA"}]
我用于调用交叉的 Jquery ajax 代码。
$.ajax({
url: "http://someDomainName/restfulservice/Api/Countries/Get_Json",
dataType: 'jsonp',
crossDomain: true,
async: false,
success: function (data) {
alert("success >> "+data);
},
error: function (jqXHR, textStatus, errorThrown) {
alert("error : "+errorThrown + ", textStatus >> "+textStatus);
}
});
每次它进入错误块。当我在浏览器中检查此服务时,它会给出带有有效 json 字符串的响应文本。但是通过代码我收到错误"jQuery18305917718204907095_1409810925309 was not called, status: parsererror".
虽然此代码适用于网址“ http://api.geonames.org/findNearbyPlaceNameJSON?lat=47.3&lng=9&username=demo ”。
同样的问题可能是什么?