When we use $.ajax object it is easy to use .ajaxComplete() to detect ajax request from any handler of document.
Is what we are working with javaScript only, no jQuery, how can we achieve same result like .ajaxComplete().
When we use $.ajax object it is easy to use .ajaxComplete() to detect ajax request from any handler of document.
Is what we are working with javaScript only, no jQuery, how can we achieve same result like .ajaxComplete().
You could do what jQuery did and create your own wrapper around XHR/ActiveX. Make sure you use it exclusively in your application and then you can have it do whatever you want (including calling back registered functions) whenever it completes a request.
Edit:
If you want to capture ANY xhr completion, check out this fiddle I made:
https://jsfiddle.net/0bjfLey9/1.
Basically you wrap the send()
function and then wrap the onreadystatechange
handler, inserting whatever logic you want into the wrapper.