Link to home
Start Free TrialLog in
Avatar of Brant Snow
Brant Snow

asked on

javascript onComplete or call back problem

K so i have a problem i have two functions that i want ran but although javascript runs things sequentially it continues on before the first finishes.  So i need someone to show me how i could use a call back, or some kind of onComplete method to wait until the first function is ran before the second one begins running
<script>

function goTime()
{
            firstFunction();
            secondFunction(); 

}

function firstFunction()
{
}

function secondFunction()
{

}

Open in new window

Avatar of sdrouins
sdrouins

I think your doing something wrong....
javascript will not call your second function until the first one is finish?

javascript is not asychronous
@sdrouins yes it is, it can be used asychronous or not

@thawts I'd need to see what is what your functions do to give a more accurate answer, but most likely you can solve it using the setTimeout() :

http://www.w3schools.com/jsref/met_win_settimeout.asp 

or a component that has the oncomplete method which depends on what techlnology are you using, but richfaces and icefaces are some examples of implementations that have components with oncomplete, cant use them if your working with .net tho, so maybe if you tell me what technolgy ur working with? (.jsp,.asp...) , gl
maybe I dont understand I question, but this guy dont want asychronous call..... I want it sequential? no?

by default firstFunction will be execute et after it finish function2 will be call?
ASKER CERTIFIED SOLUTION
Avatar of Mangagm
Mangagm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brant Snow

ASKER

s