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

Was it helpful?

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
scroll top