$(document).ready(function() { // check once in five seconds setInterval(function() { $.get('/script.php', {do: 'new_messages'}, function(response) { if(response == 1) { window.location.reload(); } }); }, 5000); });
$sql = "select * from chat order by id desc limit 15"; $result = mysql_query($sql) or die ("An error has occured with in the database.");