Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • @TheifMaster, thanks for your replay, but if I can re-enable a button, hiding a throbber, etc. in the .done() with a conditional test like : If(jqXHR.status===200) { // Re-enabling button, hiding a throbber, etc. } for example What is the necessity to have .always() function? If so, I think .always() is not necessary and should be removed from JQuery. Commented Jul 15, 2013 at 15:34
  • @ghaliloo Because always() always runs, while done() only runs if the deferred object is resolved (i.e. the ajax query was successful) Commented Jul 15, 2013 at 15:43
  • @ghaliloo No, that would only re-enable the button if the request succeeded. ThiefMaster wants to re-enable the button after the request regardless of whether it succeeded or not, and that's the use case for .always(). Commented Jul 15, 2013 at 15:44
  • @ghaliloo There is no requirement to use the always function. If it is not suitable in your case, don't use it. Commented Jul 15, 2013 at 15:45
  • @Mike, hhhhhhh hhhhhh, No, if it wasn't suitable in my case I wouldn't make a new post about it, in contrary it is very useful for me, since I want to do a task if the Differed is resolved and another if it is rejected and I have to make it in .always() as I said because it is always called, however if I put in .done() or .fail(), I have no warranty it will be executed. Commented Jul 15, 2013 at 16:01