Skip to content

Instantly share code, notes, and snippets.

@kiran-machhewar
Created March 24, 2014 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiran-machhewar/9742224 to your computer and use it in GitHub Desktop.
Save kiran-machhewar/9742224 to your computer and use it in GitHub Desktop.
function addXMLRequestCallback() {
var oldSend, oldonreadystatechange;
/*saving the orginal method*/
oldSend = XMLHttpRequest.prototype.send;
/*overrideing the default behaviour*/
XMLHttpRequest.prototype.send = function() {
/*calling the default behaviour*/
oldSend.apply(this, arguments);
oldonreadystatechange = this.onreadystatechange;
this.onreadystatechange = function ( progress ) {
oldonreadystatechange(progress);
onFinshAjaxRequest();
};
}
}
function onFinshAjaxRequest(){
//code which needs to be executed once the the ajax request is completed.
/*************************************/
/******HERE GOES YOUR JS CODE*********/
/*************************************/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment