Wrapping $.get in another deferred
-
12-12-2019 - |
Question
I'm just trying to get my head around the details of deferred.
Why doesn't the following make the two calls syncronous?
http://jsfiddle.net/JSw5y/889/
Console output:
Running ajax get
Fading in
Fading in done
Finished running ajax get
Desired output:
Running ajax get
Finished running ajax get
Fading in
Fading in done
Solution
It doesn't work because in this line:
.then(showDiv())
you're calling showDiv
immediately, not passing it as a callback to .then()
. It should read:
.then(showDiv)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow