Skip to content

Instantly share code, notes, and snippets.

@nathansearles
Created July 28, 2011 19:50
Show Gist options
  • Save nathansearles/1112388 to your computer and use it in GitHub Desktop.
Save nathansearles/1112388 to your computer and use it in GitHub Desktop.
Example usage of jQuery deferred
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Deferred</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
$targetData = function() {
var deferred = $.Deferred();
deferred.resolve();
//deferred.reject();
return deferred.promise();
};
$targetData().done(function() {
console.log( "done" );
});
$targetData().fail(function() {
console.log( "fail" );
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment