Skip to content

Instantly share code, notes, and snippets.

@dch
Forked from bojanbjelic/gist:3931503
Created October 24, 2012 13:24
Show Gist options
  • Save dch/3946030 to your computer and use it in GitHub Desktop.
Save dch/3946030 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