Using jQuery maintaining Deferred functionality - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:deferred

Description

Using jQuery maintaining Deferred functionality

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <script src="https://code.jquery.com/jquery-latest.js"></script> 
 </head> //from w ww  . j ava 2s  .c om
 <body> 
  <script>
var dfr = (function() {
  var deferred;
  deferred = jQuery.Deferred();
  setTimeout(function() {
    return deferred.resolve(JSON.stringify("test"));
  }, 10);
  return deferred;
})()
dfr.then(console.log.bind(console))

      </script>  
 </body>
</html>

Related Tutorials