Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 9, 2014 01: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 devdays/258ac5626a910da12f6e to your computer and use it in GitHub Desktop.
Save devdays/258ac5626a910da12f6e to your computer and use it in GitHub Desktop.
Object JavaScript - Deferred in jQuery
$('#result').html('waiting...');
var pro = wait();
pro.done(result);
function result() {
$('#result').html('done');
}
function wait() {
var deferred = $.Deferred();
setTimeout(function() {
deferred.resolve();
}, 2000);
return deferred.promise();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment