I have a problem with AJAX , I cant find a good solution to refresh only my div "chatwindow" every second. I have tried many posts from stackoverflow and from google.
Can someone help me... to make this.
So far my code

```
<!DOCTYPE HTML>
<?php
    include 'config.php';
?>
<html>
<head>
    <title>JavaScript Chat</title>
    <link href="style.css" rel="stylesheet" type="text/css"/>

</script>
</head>
<body>
    <div class="container">
        <div id="chatwindow">
            <?php
                $result = mysql_query("select * from Message");
                while($row = mysql_fetch_array($result))
                {
                    echo '<p>' . $row['username'] . " : " . $row['message'] . '</p>';
                }
            ?>  
        </div>

        <div class="inputMessage">
            <form method="post">
                <hr></hr>
                <textarea name="message" rows="1" cols="55"></textarea><br/>Fill username here<br/>
                <input type="submit" value="verstuur" name="submit"/>
                <input type="text" value="" name="username" />
            </form>
        <?php
            if(isset($_POST['submit'])) 
            {
                if (!empty($_POST['username']))
                {
                    if(!empty($_POST['message']))
                    {
                        $message =  mysql_real_escape_string(htmlentities($_POST['message']));
                        $username =  mysql_real_escape_string(htmlentities($_POST['username']));
                        $query = "INSERT INTO Message (`username`,`message`) VALUES ('".$username."','".$message."')";
                        mysql_query($query);
                    }
                    else
                    {
                         echo '<script type="text/javascript">alert(\'Je kan niet niks sturen\')</script>'; 
                    }
                }
                else
                {
                    echo '<script type="text/javascript">alert(\'Vul een gebruikresnaam in!\')</script>';
                }
            }
            ?>      
        </div>
    </div>
</body>
</html>

  [1]: http://chaotix.nl/chat/ "chat"

```