I have a very basic chat script that post the messages to a mySQL database. The script below (which works fine) simply selects the inputted values and echos them in the iframe where the script resides.
My problem is simply one of aesthetics. As you can tell by the Javasript near the top, the page refreshes and thus "updates" the iframe window. This refreshing though is pretty annoying and the reading I have been doing about AJAX suggest that there may be a way to update my window without the unsightly "flicker" of my crude standard method. I don't know very much anout AJAX at all but I am doing research on the subject to see if I can apply it to my situation.
Is anyone out there familiar with AJAX enough who can direct me to a good tutorial or show me how I might acheive my objective using AJAX.
As always, all responses are greatly appreciated.
<HEAD>
<script type="text/javascript">
function reFresh() {
location.reload(true)
}
window.setInterval("reFresh()",5000);
</script>
</HEAD>
<?
mysql_select_db($myDB,$myConnection);
$rs = mysql_query( "SELECT * FROM chat ORDER BY id DESC LIMIT 0,10" )or die(mysql_error());
while ( $msg = mysql_fetch_array( $rs )) {
$msg = str_replace("\'", "' ", $msg);
$msg['message']=wordwrap($msg['message'], 75, "\n", 1);
echo "<span style=\"color:red\">". $msg['login']. "</span><span style=\"color:grey\"> (". $msg['itstime']. ") </span><span style=\"color:navy\">". $msg['message']
. "</span><br />";
}
?>