Is it possible to create and attach a callback that will be called whenever the ajax request completes, regardless of whether the call was made using $.ajax , $.post , load or any other function?
EDIT:
The solution provided by Nakul (using the ajaxSuccess global event) is almost perfect. However, when using the load function, I have a problem. The ajaxSuccess event occurs after the request is completed, but before any manipulations with the DOM. I would like to execute some code after changing the DOM. My temporary solution is to use setTimeout and wait a few milliseconds, but I don't think it would be reliable enough for me.
So, another question: how can you execute the code after the DOM has been processed by the load function?
EDIT 2:
I managed to solve the second problem using the ajaxComplete event instead of ajaxSuccess.
jquery ajax callback
Marek stΓ³j
source share