InterviewSolution
Saved Bookmarks
| 1. |
What is promise and list out few Jquery methods which returns a promise object? |
|
Answer» When an ajax request made, if you want to HANDLE when the request completes then .always() will come in handy. .always() is a PROMISE callback method ADDED in jQuery 1.6 and it's a replacement for the deprecated .complete() method. For example, if you want show a loading indicator when a request made and hide the loading indicator when the request complete, in this case, .always() HANDLER can be useful. The following is the example: var jqxhr = $.ajax("example.php") .done(function() { alert("success"); }) .fail(function() { alert("error"); }) .always(function() { alert("complete"); }) |
|