How to intercept all jQuery ajax events?
I have a large JavaScript application with a lot of ajax (third party script). Now I need to intercept all ajax events, i.e. when a message from the server returns with a transport text or message, I want that text / message to perform replacements.
Problem: I tried with this, but it never responds to any ajax event. It's on the jquery examples page, and this #msg thing looks like a placeholder for something:
$("#msg").ajaxSuccess(function(evt, request, settings){
alert('ajax event');
$(this).append("<li>Successful Request!</li>");
});
Your syntax looks correct. I've triple checked the syntax .. and it seems to be fine. You mentioned that you are using third party ajax calls .... ajaxSuccess () will only fire when using jQuery ajax calls ... like $ .post, $ .get or $ .ajax.
If your ajax calls are third party calls, you will have to change all your ajax calls to use jQuery methods.
Hope this helps? This may not be entirely correct.
source to share