javascript variable setting
I have a small if statement that runs when a function is run. The issue is that th开发者_Go百科e variable timeout_value is always defined as 0 even after the if statement executes successfully. What am I doing wrong?
//update on interval
var timeout_value=0;
//set interval based on number of users
if (json.countusers==2 && timeout_value!=3){
alert(timeout_value);
timeoutID2 = setInterval(refresh, 3000);
timeout_value=3;
}
Are you defining var timeout_value=0;
in the right scope? Move it out of your method.
Do you call this from inside a function? var
makes the variable local, so it is not available in the global scope.
精彩评论