[thelist] Javascript: run a function once a function is complete

Christian Heilmann codepo8 at gmail.com
Mon Jan 9 07:00:22 CST 2006


> > I've started working on small javascript app, what i need to do now is run a
> > function once another function has completed,
>
> > this is new territory for me so i maybe missing something very obvious, any
> > pointers much appreciated.
>
> Maybe I'm also missing something, but what's wrong with this:
>
> function A() {
> /*
>         code...
> */
>         B();
> }
>
> function B() {
>         echo("Hey, this works!");
> }
>
> which runs B() at the end of A().

Depends, if A is an AJAX load thingy then you need to monitor the
readyState to see when the whole thing was loaded (4), and also
provide a timeout fallback in case it simply takes too long.


--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/



More information about the thelist mailing list