title: Loading external php file in a div with jquery ajax
body: <p>i am making a simple project..and i need to load data from other page in an<br>
      index.php..and i have set time of 20sec. but its not working.. could u please 
       tell me what is wrong with the query..Thanks already..</p>
  
  <h2>index.php</h2>
  
  <pre><code>   &lt;?php
     include 'connection.php';
  
     ?&gt;
     &lt;html&gt;
     &lt;head&gt;
     &lt;title&gt;
     My First Chat app
     &lt;/title&gt;
    &lt;link rel="stylesheet" type="text/css" href="style.css"&gt;
             &lt;script&gt;
  
  
          $(document).ready(function(e) {
     $.ajaxSetup({cache:false});
     setInterval(function(){$('#logs').load('logs.php'); } ,2000);
   });
    &lt;/script&gt;
  
     &lt;/head&gt;
    &lt;body&gt;
    &lt;center&gt;&lt;h1&gt;Chat Box in PHP!!&lt;/h1&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/center&gt;
   &lt;form name="form1"&gt;
    &lt;center&gt;
  
  
    &lt;strong&gt;Username:&lt;/strong&gt;&lt;input type="text" name="uname"              
   style="width:200px;"&gt;&lt;br&gt;&lt;br&gt;
  
   &lt;strong&gt; Message:&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;textarea name="msg"      
  style="width:201px;"&gt;&lt;/textarea&gt;
   &lt;br&gt;
   &lt;a href="#" onClick="sheikh()"&gt;Send&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
    &lt;/center&gt;
  &lt;div id="logs"&gt;
   &lt;br&gt; &lt;img src="icon.png"&gt;Loading chatlogs please wait...
   &lt;/div&gt;
  
    &lt;/form&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <h2>   logs.php</h2>
  
  <pre><code>    &lt;?php
  
         $con=mysqli_connect("localhost","root","","chat");
       $sqli="SELECT * FROM `logs` ORDER BY `id` DESC";
        $result=mysqli_query($con,$sqli);
         while($res=mysqli_fetch_assoc($result)){
       echo "&lt;span class='uname'&gt;" .$res["username"]."&lt;/span&gt;:&lt;span                          
       class='msg'&gt;"  .$res["message"]. "&lt;/span&gt;&lt;br&gt;";
      }
    ?&gt;
  </code></pre>