Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - Set timer to run once then execute a function

Tags:

jquery

timer

So I have another plugin that takes a second to load because it has to get some info, so I plan on making it so that it runs on about a 3 second timer, during the 3 seconds it will display something like "Loading Statistics" then slides down the statistics judging that they took 3 seconds or less to load, heres my current code, but it keeps repeating http://jsfiddle.net/7tkGY/

Thanks =) - Necro

like image 887
Necrohhh Avatar asked Sep 29 '12 21:09

Necrohhh


1 Answers

window.setTimeout(func,3000);

setInterval is a repeating function. if you want to end a setinterval you must do this

var interval = window.setInterval(func,3000);
 clearInterval(interval);

setTimeout(func,time) runs the function only onces

like image 72
Anton Avatar answered Dec 01 '22 18:12

Anton