[英]jQuery.getJSON().error() isn't being executed on 404 error
This is a brief outline of my code: 这是我的代码的简要概述:
$.getJSON(json_url, function(data) {
// application logic
}).error(function() {
console.log("error");
});
The problem is that when the server returns a 404 error, it does not appear to be handled as there is no console.log()
saying error, but there is a GET request failure with a code of 404 (Not Found)
showing up in the console. 问题是,当服务器返回404错误时,它似乎没有被处理,因为没有console.log()
说错误,但有一个GET请求失败,代码为404 (Not Found)
显示在控制台。
I am using jQuery 1.9.0. 我正在使用jQuery 1.9.0。
Is there some simple error I am making? 我正在制作一些简单的错误吗?
Due to the nature of JSONP requests, the error callback is not called for those. 由于JSONP请求的性质,不会为这些请求调用错误回调。
When data is retrieved from remote servers (which is only possible using the
script
orjsonp
data types), the error callbacks and global events will never be fired. 从远程服务器检索数据时(只能使用script
或jsonp
数据类型),永远不会触发错误回调和全局事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.