Reputation: 127
G'day All,
A page that is created by a 3rd party they have the following code:
$(document).ajaxError(function(event, request, settings) {
alert(SOME ERROR HERE);
});
I can add my own code but cannot touch theirs I would like to override that because it is messing with my ajax get. By the time it gets to my step theirs has already run so if I could somehow get it reset or nullified that would be great.
I have written the exact same code with no alerts in my function but it ignores it and calls theirs.
Any ideas?
Thank you
Upvotes: 3
Views: 2146
Reputation: 710
You can do :
$(document).off('ajaxError');
See jQuery source for more info
Upvotes: 16
Reputation: 1447
You can disable all global event handlers for an ajax call, by setting global: false
. See Disabling some jQuery global Ajax event handlers for a request, and global ajax event handlers.
You can still use the handlers that you define locally in your ajax call.
Upvotes: 2
Reputation: 18354
I'm sorry, but it's impossible. The 3rd party added that event listener, and you can also add event listeners, but you can't remove them.
You can only add more .ajaxError()
handlers and try to 'counter-attack' the 3rd party behavior, but you can't remove it.
Hope this helps. Cheers
Upvotes: -1