View Full Version : javascript function to run using setInterger

08-21-2011, 11:20 PM
My apologies if this is not formatted correctly as I am on my phone and not everything displays correctly.

I am trying to write a class or function (not sure which is needed) that controls stats on my page. I currently have a working example but I need additional functionality and I'm not sure how to do it. Basically it needs to run every 6 seconds to update the stats(as they change constantly).

I need the javascript to connect(using ajax) to a database and retrieve stats to initially store as global variables. Then, as stated, I need it to modify(simple math that I can do) these stats every 6 seconds.

08-21-2011, 11:54 PM
just call your function that checks the database from within setInterval, something like


you may need to call the function that displays your stats again once the new ones come in (most likely from a callback function, to give the page time to load the new stats... although if you are constantly reloading the stats maybe you can get away without this and just have a lag), depending on how your code is set up

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum