Skip to content

Instantly share code, notes, and snippets.

@bojanbjelic
Created October 22, 2012 13:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bojanbjelic/3931503 to your computer and use it in GitHub Desktop.
Save bojanbjelic/3931503 to your computer and use it in GitHub Desktop.
jQuery ajax wait pattern
function getTwoThings( callback ) {
var peopleRequest = $.getJSON( '/data/people.json' );
var taskRequest = $.getJSON( '/data/tasks.json' );
$.when( peopleRequest, taskRequest )
.done(function( people, tasks ) {
callback( people[0].people, tasks[0].tasks );
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment