简体   繁体   中英

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.

By using jquery.ajax, when can I expect the fail callback to be run?

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 :

  • http error code equal to or greater then 400

  • missing CORS headers

what are the other cases when jquery will run the fail callback?

When the response status returned is 4xx or 5xx, which indicates a client-side or server-side error respectively. Here's the entire list of such status codes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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