Skip to content

Instantly share code, notes, and snippets.

@pbojinov
Created February 19, 2014 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pbojinov/9101153 to your computer and use it in GitHub Desktop.
Save pbojinov/9101153 to your computer and use it in GitHub Desktop.
Multiple Simultaneous Ajax Requests (with one callback) in jQuery
// http://css-tricks.com/multiple-simultaneous-ajax-requests-one-callback-jquery/?utm_source=javascriptweekly&utm_medium=email
$.when(
// Get the HTML
$.get("/feature/", function(html) {
globalStore.html = html;
}),
// Get the CSS
$.get("/assets/feature.css", function(css) {
globalStore.css = css;
}),
// Get the JS
$.getScript("/assets/feature.js")
).then(function() {
// All is ready now, so...
//globalstore.css
//globalstore.html
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment