Skip to content

Instantly share code, notes, and snippets.

@cmarkle27
Created August 4, 2012 22:23
Show Gist options
  • Save cmarkle27/3260350 to your computer and use it in GitHub Desktop.
Save cmarkle27/3260350 to your computer and use it in GitHub Desktop.
jQuery Ajax using when
function doAjax(){
return $.get('/echo/html/');
}
function doMoreAjax(){
return $.get('/echo/html/');
}
$.when( doAjax(), doMoreAjax() )
.then(function(){
console.log( 'I fire once BOTH ajax requests have completed!' );
})
.fail(function(){
console.log( 'I fire if one or more requests failed.' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment