Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var myVar;
- var myFunc = function(){
- var deferred = new $.Deferred();
- setTimeout(function(){
- myVar = 'hellow world';
- deferred.resolve();
- }, 2000);
- return deferred.promise();
- }
- myFunc().then(
- //Done
- function(){
- console.log('success ' + myVar);
- },
- //Failed
- function(){
- console.log('failed');
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement