• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 440
  • Last Modified:

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

0
Brant Snow
Asked:
Brant Snow
  • 2
  • 2
1 Solution
 
sdrouinsCommented:
I think your doing something wrong....
javascript will not call your second function until the first one is finish?

javascript is not asychronous
0
 
MangagmCommented:
@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
0
 
sdrouinsCommented:
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?
0
 
MangagmCommented:
It does execute firstFunction first, but if that function calls something else and it takes a long to proccess, the goTime function will continue its proccess calling secondFunction even if first hasnt finished, you usually dont notice this because all actions are done to quick, but it does happens, especially when using another library or special components that prolly make ajax transactions.
0
 
Brant SnowAuthor Commented:
s
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now