Created
February 14, 2014 00:19
-
-
Save irazasyed/8986812 to your computer and use it in GitHub Desktop.
JS: jQuery Multi-AJAX Handling
This file contains 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
$.when( | |
// Get the HTML | |
$.get("/feature/"), | |
// Get the CSS | |
$.get("/assets/feature.css"), | |
// Get the JS | |
$.getScript("/assets/feature.js") | |
).then(function(html, css, script) { | |
// do stuff | |
}); | |
// To handle fail: | |
$.when( | |
// get template | |
// get json | |
).done(function( template, json ) { | |
// Everything OK | |
}).fail(function() { | |
// One of the sources is not available | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment