Skip to content

Instantly share code, notes, and snippets.

@snippe
Created November 20, 2014 04:16
function A() {
return $.ajax({
url: 'http://echo.jsontest.com/a/1',
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
}
function B(fromA) {
console.log(fromA);
return $.ajax({
url: 'http://echo.jsontest.com/b/2',
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
}
function C(fromB) {
console.log(fromB);
return $.ajax({
url: 'http://echo.jsontest.com/c/3',
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
}
function D(fromC){
console.log(fromC);
}
$.when(A())
.done(B)
.done(C)
.done(D);
//Object {a: "1"}
//Object {a: "1"}
//Object {a: "1"}
//Object {a: "1"}
//Object {b: "2"}
//Object {c: "3"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment