0

Is there is any way to disable the call to local error function defined in the Ajax request from global error defined in ajaxError

I have tried numerous ways but unable to disable the call to local error function defined in ajax function, Is that possible?

Note: I do not want to modify local error function or $.ajax because $.ajax is used in number of places.

        $( document ).ajaxError(function( event, jqxhr, settings, exception ) {
            if(jqxhr.status == 401 || jqxhr.status == 403) {
               //customize error response

               //disable call to local error 
            }           
        });
$.ajax({
   error:function(jqXHR, textStatus, errorThrown){
   // local error
   }
})```
Piyush Sharma
  • 591
  • 7
  • 9
  • I don't think you can do it. I just looked at the source code, and `$.ajax` turns the `error:` option into a `.fail()` callback on the `Deferred` object. I'm not sure there's a way to remove those. – Barmar Feb 27 '20 at 22:50
  • You mean like this https://stackoverflow.com/a/7462590/4929742 ? – Bilel Feb 28 '20 at 00:11
  • @Bile that is to disable global ajax evens whereas the one I needed is the opposite of it, need to disable local error event from global error event. – Piyush Sharma Feb 28 '20 at 14:12

0 Answers0