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
https://forums.phpfreaks.com/topic/194210-does-setinterval-work-outside-onload/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.