Skip to content

Instantly share code, notes, and snippets.

@irazasyed
Created February 14, 2014 00:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irazasyed/8986812 to your computer and use it in GitHub Desktop.
Save irazasyed/8986812 to your computer and use it in GitHub Desktop.
JS: jQuery Multi-AJAX Handling
$.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