Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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.

JavaScript
var continue = true;
while(continue)
{
  if(stop loop)
     continue = false;
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900