What is jquery Deferred and Promise?
jQuery the java-script framework help us to write concise java-script code, in this blog I am going to introduce about powerful feature of jQuery some people found it difficult to understand or ignore/forgot it once they done with the task. So let's begin: The definition of deferred and promise can be found easily by googling it :-), so we are directly begin with the implementation or coding. Since most of the developer are familiar with ajax so first I would like to start with ajax and then we will look how to use deferred. A html div :- <div id="mydiv"> </div> <div id="mydiv2"> </div> js code :- $.ajax({ url:'/echo/json/', context:document.body, success:function() { $('#mydiv').text('ajax success'); }, error:function() { $('#mydiv').text('ajax error'); } }); Here success and error handlers are the callback functions and will be invoked when ajax succeeded...