EasyUI Forum

General Category => General Discussion => Topic started by: Pierre on July 29, 2013, 11:02:07 AM



Title: JavaScript callback
Post by: Pierre on July 29, 2013, 11:02:07 AM
Hello all
I have this code:

function  myfunc()
{
  func1();
  func2();
  func3(); 
}

I need that func2 run after func1 finished, and func3 should run when func2 is finished.
They are executed as 1,2,3 but they are not finished on that order (for example, func2 is slow and it is not returned, but func3 is already executed.
Question is - how to run those functions so that I'm sure that next function is executed only when previous function is finished?

Thanks.


Title: Re: JavaScript callback
Post by: chrwei on August 15, 2013, 08:34:50 AM
that depends on what's happening inside those functions.  if they are async calls of some sort (ajax, timers) then you need to handle that somehow so that the function does not return until its work is complete.