Last active
August 29, 2015 14:23
-
-
Save jumplee/dc92e047178b72e69b60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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