简体   繁体   English

什么时候jquery.ajax运行失败回调?

[英]When exactly does jquery.ajax run the fail callback?

I cannot find this in the documentation. 我在文档中找不到这个。 I also did a run through the jquery source and can't find any more info. 我还浏览了jquery源代码,无法找到更多信息。

By using jquery.ajax, when can I expect the fail callback to be run? 通过使用jquery.ajax,我什么时候可以运行失败回调?

Apart of the following: 除以下内容:

  • connection problem ( eg mobile device lost connection ) 连接问题(例如移动设备丢失连接)
  • server is down and does not respond 服务器已关闭但无响应

    // EDIT: added after comments, a lot of thanks to @charlietfl : //编辑:评论后添加,非常感谢@charlietfl:

  • http error code equal to or greater then 400 http错误代码等于或大于400

  • missing CORS headers 缺少CORS标头

what are the other cases when jquery will run the fail callback? 当jquery运行失败回调时的其他情况是什么?

When the response status returned is 4xx or 5xx, which indicates a client-side or server-side error respectively. 返回的响应状态为4xx或5xx,分别表示客户端或服务器端错误。 Here's the entire list of such status codes. 以下是此类状态代码的完整列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM