我发送GET请求(它返回JSON)。代码看起来像:GET ajax请求
$.ajax({
url: "http://www.new.marketprice.ru/retrieveRegions.html",
dataType: "jsonp",
data: {
searchStr: request.term
},
error: function() {
console.log('epic fail');
},
success: function(data) {
console.log(data);
}
});
它返回(到控制台);
Resource interpreted as Other but transferred with MIME type undefined.
epic fail
但Network
标签我看到返回的数据GET请求:
[
{ "region":"Московская область","countryId":1,
"cityId":23,"regionId":12345,"city":"Москва","country":"Россия"},
{"region":"Ленинградская область","countryId":1,"cityId":453,
"regionId":54321,"city":"Санкт Петербург","country":"Россия"}
]
为什么error
回调叫什么名字?
UPD
好吧,我设置json
现在没有警告,但错误:
XMLHttpRequest cannot load http://www.new.marketprice.ru/retrieveRegions.html?searchStr=test. Origin http://new.marketprice.ru is not allowed by Access-Control-Allow-Origin
它是如此奇怪,因为运行脚本位于同一个域中:(
是在该请求页面不同域的网址试试? (json vs jsonp dataType。) – BNL
如果它位于同一个域中,请用'“/retrieveRegions.html”' – Blazemonger
@ mblase75替换'“http://www.new.marketprice.ru/retrieveRegions.html”'非常感谢!它现在有效。 – Ockonal