jQuery Ajax 404处理 [英] jQuery Ajax 404 Handling
问题描述
我正在尝试访问404事件,我可以看到它带有Firebug再次返回404,但是错误功能没有启动,使用下面的代码,我总是会收到错误:成功?.
Im trying to access a 404 event which I can see coming back as 404 with firebug but the error function is not kicking in, With my below code I always get Error: success ?.
即.
$.ajax({
type: 'get',
url: 'url: 'https://admin.instantservice.com/resources/smartbutton/5702/10945/available.gif?' + Math.floor(Math.random()*10001),
success: function(data, textStatus, XMLHttpRequest){
console.log('Error: ' + textStatus);
},
error:function (xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(xhr.statusText);
alert(xhr.responseText);
}
});
同样,我知道1000%的用户在Firebug中发现404 Not Found永远不会触发错误.
Again I know 1000% that im getting 404 Not Found in firebug it never triggers the error.
我错过了什么吗?
推荐答案
跨站点请求JSONP不会触发错误调用.我自己也遇到了同样的问题: http://forum.jquery.com/topic/jquery-ajax-with-datatype-jsonp-will-not-use-error-callback-if-request-fails
Cross Site requests, JSONP, wont trigger the error calls. Just had the same problem myself: http://forum.jquery.com/topic/jquery-ajax-with-datatype-jsonp-will-not-use-error-callback-if-request-fails
这篇关于jQuery Ajax 404处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!