Last active
August 29, 2015 13:57
-
-
Save cheeyeo/9761926 to your computer and use it in GitHub Desktop.
TRACK AJAX REQUESTS Success callback across multiple js files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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