Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Last active August 29, 2015 13:57
Show Gist options
  • Save cheeyeo/9761926 to your computer and use it in GitHub Desktop.
Save cheeyeo/9761926 to your computer and use it in GitHub Desktop.
TRACK AJAX REQUESTS Success callback across multiple js files
//Within jquery you can listen to global ajax event handlers for the outcome of any ajax requests for when you want to write
// your own callback from predefined ajax calls
// e.g.
// the below js call is in a separate js file say 'main.js'
function makeAjaxCall(){
//...
$.ajax({
url: 'http://something.com'
});
}
// below is your own code in a separate file you want to define a callback for ..
// say 'myfile.js'
function mycustomcallback(){
$( document ).ajaxSuccess(function( event, request, settings ) {
if(settings.url.match('http://something.com')){
// activate your callback here
}
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment