Click to See Complete Forum and Search --> : automatically running a function every few seconds


jrottman
08-17-2005, 12:42 AM
Hi, I am trying to build a chat program for experience reasons. I have a javascript function which sends out the http request, returning the data, and updating the screen. Is there a way I can set this function to automatically run like every 3 seconds? Thank you!

Jason


function updateChatBox()
{
http.open("GET", "getconversation.php", true);
http.onreadystatechange = handleHTTPResponse;
http.send(null);
}

shinujohn
08-17-2005, 01:41 AM
try this:

function updateChatBox()
{
http.open("GET", "getconversation.php", true);
http.onreadystatechange = handleHTTPResponse;
http.send(null);
setTimeout('updateChatBox() ',3000); // setTimeout(expression,milliseconds);
}

updateChatBox() ;

Shinu