title: Ajax auto refresh comment wall
body: <p>Alright, so after several days of searching and reading I still can't get this to work so this is kinda my last chance. Keep in mind i'm a rookie with Ajax and JS.</p>
  
  <p>I have a comment wall where you can leave a nice little message to others on the page and it works just fine but now I want to add some ajax so it auto refresh every 10 second and get the latest comments.</p>
  
  <p>The thing is I get the whole website to be displayed inside that div and not the comments.</p>
  
  <p>I have a js document with the following code</p>
  
  <pre><code>  (function update() {
      $.ajax({
          type : 'GET',
          url : 'index.php',
          success : function(data){
              $('#cmt_wall_container').html(data);
          },
      }).then(function() {
         setTimeout(update, 10000);
      });
  })(); 
  </code></pre>
  
  <p>And my Index.php page include the following</p>
  
  <pre><code>&lt;?php include_once 'connect.php'; ?&gt;
  &lt;?php 
  $cmt_list = "";
  $sql = mysqli_query($con, "SELECT * FROM cmt ORDER BY id DESC LIMIT 10");
  $cmtCount = mysqli_num_rows($sql);
  if($cmtCount &gt; 0){
      while($row = mysqli_fetch_array($sql)){
         $id = $row["id"];
         $comment = $row["comment"];
         $cmt_list .="&lt;div class='post-container'&gt;&lt;p class='post-comment'&gt;$comment&lt;/p&gt;&lt;/div&gt;";
  }
  } else {
      $cmt_list = "leave a comment";
  }
  ?&gt;
  
  &lt;head&gt;stuff..&lt;/head&gt;
  &lt;body&gt;
      &lt;div id="cmt_wall_container"&gt;
          &lt;?php echo $cmt_list; ?&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I hope this is clear enough!
  Thank you very much in advance, you are really my last hope!!!!!</p>