Web Analytics Made Easy -
StatCounter javascript function to run using setInterger - CodingForum

Announcement

Collapse
No announcement yet.

javascript function to run using setInterger

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • javascript function to run using setInterger

    Hi,
    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.

  • #2
    just call your function that checks the database from within setInterval, something like

    setInterval("checkStats()",6000);

    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
    Last edited by xelawho; Aug 21, 2011, 05:57 PM. Reason: forgot about callback, again

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎