I’m trying to get an event to fire after five minutes. I’m using the following code:
setTimeout(tweet(name, type), 5 * 60 * 1000);
It is firing after a while, but not nearly five minutes (Usually two minutes or so, but sometimes it’s instant.). What am I doing wrong? (I’ve also tried setting the time to 300000 instead, same problem.
You are calling
tweetimmediately and passing its return value tosetTimeout.You need to pass a function to
setTimeout. You haven’t included the code fortweet, but I’m going to assume that it doesn’treturna function.