Philip Kirkbride Philip Kirkbride - 11 months ago 81
Javascript Question

How to use jQuery .When .done

I'm trying to run one function after another function completes.


Each function works fine on it's own but when I run the code above it only runs the first function.

What do I need to change?

Answer Source

Looking back at this now, this seems to be how it works with jQuery:

function f1() {
	alert("function one");

$.when( f1() ).done(function() {
  alert("function 1 is done running function two");
<script src=""></script>

Note: This is identical to my method I posted in the question so essentially it should have worked. Though jQuery may have changed over the last 3 years.