Make sure this functions is the first thing loaded to the browser:
(function(open) {
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
this.addEventListener("readystatechange", function() {
//Put your code here
}, false);
open.call(this, method, url, async, user, pass);
};
})(XMLHttpRequest.prototype.open);
Each time an ajax response is retrieve, the following listner functions is called, and is in there that you should put your code:
this.addEventListener("readystatechange", function() {
//Put your code
}, false);
Note:
This code was extracted from this answer which was used to intercept all ajax requests and from this answer you don't need to pass the parameters on functions:
(function(open) {
XMLHttpRequest.prototype.open = function() {
this.addEventListener("readystatechange", function() {
// put your code here!
}, false);
open.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);