XHR Listener
// Add jquery here
(function() {
var proxied = window.XMLHttpRequest.prototype.send;
window.XMLHttpRequest.prototype.send = function() {
//Here is where you can add any code to process the request.
//If you want to pass the Ajax request object, pass the 'pointer' below
var pointer = this
var intervalId = window.setInterval(function(){
//0: request not initialized
//1: server connection established
//2: request received
//3: processing request
//4: request finished and response is ready
if(pointer.readyState != 4){
return;
}else if(pointer.readyState == 4){
//code here
}
// will be raised whenever an AJAX request co
//Here is where you can add any code to process the response.
//If you want to pass the Ajax request object, pass the 'pointer' below
clearInterval(intervalId);
}, 1);//I found a delay of 1 to be sufficient, modify it as you need.
return proxied.apply(this, [].slice.call(arguments));
};
})();
0 comments: