我正在使用jQuery制作简单的自动提示(autocompleter)插件.不幸的是我必须使用jsonp.没关系,它可以工作,但是当我中止请求时,它会抛出错误.
Uncaught TypeError: Property 'jQuery171036404498340561986_1330693563756' of object [object Window] is not a function
Run Code Online (Sandbox Code Playgroud)
有代码
if(xhr) {xhr.abort()};
xhr = $.ajax({
url: "someurl/getmedata",
type: 'get',
dataType: 'jsonp',
data: {q: "query"},
success: function(results) {},
error: function() {}
})
Run Code Online (Sandbox Code Playgroud)
使用json,xml或其他请求的经典方式可以正常工作.
安妮的建议?
我正在请求带有ajax的URL,导致HTTP头代码500.我希望这会触发错误函数:
$.ajax({
url: "http://xxx",
dataType: "jsonp",
crossDomain: true,
success: function( data ) {
alert('success');
},
error: function () {
alert('error');
}
});
Run Code Online (Sandbox Code Playgroud)
这适用于safari,但在chrome和firefox中失败.
我究竟做错了什么?
这是最新的jquery 1.4.X,因为我无法升级到更高版本..
响应发送HTTP代码500,内容类型application/json和内容:
jsonp1310063232212({"error":{"reason":"User not found"}})