PDA

View Full Version : automatic div refresh


space cowboy
06-17-2009, 01:24 AM
Hi, a newbie to Ajax here so easy to understand answers, please :)


Im trying to build a VERY simple chat function on a page.

I have one text field, when someone types into this and clicks enter, the text is automatically written to the database (im using PHP and mySQL). I have this bit working fine.

Just above this text field I have a div tag which pulls all the entries out of the database. I need this to automatically refresh (say every 10 seconds) without any input or changes from the user. How can I do this?

any help would be very much appreciated :D

The PHP Guy
06-21-2009, 07:40 AM
Try this:


function updateTextBox() {
//Get info from server
//and update the text box/whatever
}
textBoxUpdateInterval = setInterval(updateTextBox, 10 * 1000);

space cowboy
06-28-2009, 06:51 PM
thanks, but as I said im a complete newbie to ajax. Where do I actually put that code you gave me? and how does it tie in with my chat area (the div id is "ajaxChat")?

cheers