How do you automatically refresh part of a page automatically using AJAX?

Posted by Ryan on Stack Overflow See other posts from Stack Overflow or by Ryan
Published on 2010-03-16T20:19:07Z Indexed on 2010/03/16 22:01 UTC
Read the original article Hit count: 163

Filed under:
|
$messages = $db->query("SELECT * FROM chatmessages ORDER BY datetime DESC, displayorderid DESC LIMIT 0,10");
while($message = $db->fetch_array($messages)) {
    $oldmessages[] = $message['message'];
}
$oldmessages = array_reverse($oldmessages);
?>
<div id="chat">
<?php
for ($count = 0; $count < 9; $count++) {
    echo $oldmessages[$count];
}
?>
<script language="javascript" type="text/javascript">
<!--
setInterval( "document.getElementById('chat').innerHTML='<NEW CONTENT OF #CHAT>'", 1000 );
-->
</script>
</div>

I'm trying to create a PHP chatroom script but I'm having a lot of trouble getting it to AutoRefresh

The content should automatically update to , how do you make it do that? I've been searching for almost an hour

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about AJAX