Skip to content

Instantly share code, notes, and snippets.

@gjohnson
Created January 19, 2011 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjohnson/785463 to your computer and use it in GitHub Desktop.
Save gjohnson/785463 to your computer and use it in GitHub Desktop.
Promise Chaining
var jxhr = $.ajax('foo.php', {
type: 'get',
dataType: 'json',
success: function (r) {
console.log('1');
jxhr.success(function(r){
console.log('4');
});
}
});
jxhr.success(function(r){
console.log('2');
});
jxhr.success(function(r){
console.log('3');
if (r[0] === 'one') {
jxhr.complete(function(r){
console.log('5');
});
}
});
console.log('whats up?');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment