I am using $.when().then() to process functions in a particular order. Everything works as expected but if a function in when requires alot of DOM manipulation or a relatively slow ajax request, the function in then gets executed before the when is complete. I duplicated the results on JSFiddle:
run_last should be ran last, but as you can see it doesn’t. Am I using when/then incorrectly in this case? Any help would be appreciated!
fixes the problem. You were passing a directly executed
$.getrequest in tothen, rather than a callback which will run the get request.