Jquery Ajax error handling to ignore aborted

后端 未结 9 752
栀梦
栀梦 2020-12-07 17:35

I want to have a global error handling method for ajax calls, this is what I have now:

$.ajaxSetup({
  error: function (XMLHttpRequest, textStatus, errorThro         


        
9条回答
  •  天涯浪人
    2020-12-07 17:58

    You'll want to look at the textStatus argument passed into your error function. According to http://api.jquery.com/jQuery.ajax/, it can take the values "success", "notmodified", "error", "timeout", "abort", or "parsererror". "abort" is obviously what you want to check against.

    Longer notes here: jquery-gotcha-error-callback-triggered-on-xhr-abort

提交回复
热议问题