Click here to Skip to main content
14,667,814 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hai,

var t;

function start()
{
   t=setTimeout('call',1000);
}

function call()
{
while(true)
{
...
...
}
}


Some condition i should stop the function call loop. So i am using clearTimeout(t). But its not working. The while loop is still continue. So how to stop the while loop.
Posted
Updated 27-Jan-12 1:51am
v2
Comments
Rajesh Anuhya 27-Jan-12 7:51am
   
pre tags added
--RA

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Your while loop will always continue because you are using TRUE. clearTimeout makes no difference because the function has already been called and the while loop is processing. You need to use some other comparison; something like this.

var continue = true;
while(continue)
{
  if(stop loop)
     continue = false;
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100