You can also see the exception in the JavaScript console. Dtipson Dtipson 1, 14 14 silver badges 20 20 bronze badges. Deferred ; defer. Interesting aspect that a jQuery. Deferred can receive multiple values, which it properly passes on to the first. The chosen interface via return can only return one value. Which is more consistent, to be honest. There is a very simple mental mapping in response that was a bit hard to find in the other answers: done implements tap as in bluebird Promises then implements then as in ES6 Promises.
B M B M 3, 3 3 gold badges 24 24 silver badges 41 41 bronze badges. Only use. Proof The following code snippet reveals, that: all. Robert Siemer Robert Siemer A few things: 1 I see what you are saying that done will not be executed if a previous done has an exception. But why would it be silently ignored, I mean an exception occurred so why do you say it is silent. It is too complex and confusing.
Your code here does not help either to prove your point and it has too much un-needed complexity for what you are trying to prove. My bad, ya definitely deserves a vote. As for your comment about the exception, normally that's how exceptions work: once raised, code after it won't be executed.
Plus the jQuery documentation states that it will only be executed if the deferred is resolved. But I see no reason why a completely different success-handler on a successful promise is not called. Code and text. Thank you.
This answer explained the behavior I was seeing. I was using then. My test was failing because the callback was called async, after the test was over. Using done the callback is called synchronously, satisfying the test expectations, and the test passes. In addition to the answers above: The real power of. Stephan van Hoof Stephan van Hoof 7 7 bronze badges.
This answer would be correct for several promise implementations but not jQuery, in which. The documentation says, "Since deferred. My bad, did not check the jQuery — gleb bahmutov. Just a friendly suggestion : — Andrey. Please don't delete the answer, this can help people clear up their misunderstandings too.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Linked 2. Therefor it considers the animation done and executes for 0ms instead of the expected ms. So it immediately starts fading in all of the.
Asked 3 Months ago Answers: 5 Viewed 65 times. Can someone see what I'm missing? Thanks for any help. Main call: this. TaskHours data ; self. Andrew Stakhov. An important benefit of this in terms of maintainability is that you've wrapped your ajax mechanism in an application-specific function.
All the other references throughout the app can remain the same. For example:. If you need async: false in your ajax, you should use success instead of. Else you better to use. This is from jQuery official site:.
0コメント