0

I have a small if statement that runs when a function is run. The issue is that the 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;
}
1
  • 1
    What does "refresh()" look like? Commented Aug 3, 2011 at 23:13

2 Answers 2

1

Are you defining var timeout_value=0; in the right scope? Move it out of your method.

Sign up to request clarification or add additional context in comments.

Comments

1

Do you call this from inside a function? var makes the variable local, so it is not available in the global scope.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.