Using jQuery deferred
For some reasons I keep forgetting how to use jQuery deferred objects. Let’s write down some usage examples:
Attaching multiple callbacks to an AJAX request
You can also use $.when
, that allows a variable number of deferred objects:
Running a callback after multiple AJAX requests
The callback will run when all requests are complete.
If the when
function receives more than an argument then the callback parameters will be objects like this and not the request content!
Links
- http://stackoverflow.com/questions/4869609/how-can-jquery-deferred-be-used