Skip to content

Instantly share code, notes, and snippets.

@jumplee
Last active August 29, 2015 14:23
Show Gist options
  • Save jumplee/dc92e047178b72e69b60 to your computer and use it in GitHub Desktop.
Save jumplee/dc92e047178b72e69b60 to your computer and use it in GitHub Desktop.
function fun1(){
var dfd=$.Deferred();
setTimeout(function(){
console.log('---fun1---');
console.log((new Date()));
dfd.resolve();
},2000);
return dfd.promise();
}
function fun2(){
var dfd=$.Deferred();
setTimeout(function(){
console.log('---fun2---');
console.log((new Date()));
dfd.resolve();
},2000);
return dfd.promise();
}
//-----1
// fun1().done(fun2).done(function(data){
// console.log('---done function---');
// console.log((new Date()));
// });
//-----2
fun1().done(function(){
fun2().done(function(data){
setTimeout(function(){
console.log('---done function---');
console.log((new Date()));
},1000)
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment