-3

I have the following line in my javascript code

setTimeout(reload(), 30000);

Which I expect to wait 30 seconds then call the reload function.

The issue is that the reload function is being called right away and not waiting for the timeout, why is the setTimeout calling the reload function right away and not waiting the specified amount of time? The setTimeout call is also being done in an onloadend FileReader function if that would make any difference.

jgr208
  • 2,896
  • 9
  • 36
  • 64

1 Answers1

5

setTimeout accepts a function as the first argument, unless reload() return a function to be run, you probably wanted

setTimeout(reload, 30000);
Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308