Jump to content

Does setInterval work outside Onload?


woolyg

Recommended Posts

Is it possible to call setInterval halfway down a page, or from an AJAX call?

 

I have a page, and what I'd like to happen is that when someone clicks a link, a div opens up for them, showing current info (all good, works fine). What I'd like to do then is to use setInterval() to update the Div I've just opened, and refresh the data.

 

Is this possible?

 

When I use

 

<body onLoad="setInterval('update_online_users()', '5000');" >

 

..that updates the div fine, but I don't want it to be updating the div when the page loads, only when the AJAX call is made to populate the div in the first instance.

 

At the end of my AJAX call I use

 

<script type="text/javascript">
setInterval('update_online_users()', '5000');
</script>

..but it doesn't work.

 

 

Can anyone shed any light on whether I'm barking up the right tree?

 

WoolyG

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.