0

i am making a simple project..and i need to load data from other page in an
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..

index.php

   <?php
   include 'connection.php';

   ?>
   <html>
   <head>
   <title>
   My First Chat app
   </title>
  <link rel="stylesheet" type="text/css" href="style.css">
           <script>


        $(document).ready(function(e) {
   $.ajaxSetup({cache:false});
   setInterval(function(){$('#logs').load('logs.php'); } ,2000);
 });
  </script>

   </head>
  <body>
  <center><h1>Chat Box in PHP!!</h1><br><br><br></center>
 <form name="form1">
  <center>


  <strong>Username:</strong><input type="text" name="uname"              
 style="width:200px;"><br><br>

 <strong> Message:</strong>&nbsp;&nbsp;&nbsp;<textarea name="msg"      
style="width:201px;"></textarea>
 <br>
 <a href="#" onClick="sheikh()">Send</a><br><br><br><br>
  </center>
<div id="logs">
 <br> <img src="icon.png">Loading chatlogs please wait...
 </div>

  </form>
 </body>
 </html>

logs.php

    <?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 "<span class='uname'>" .$res["username"]."</span>:<span                          
     class='msg'>"  .$res["message"]. "</span><br>";
    }
  ?>
4
  • 1
    You have not added jQuery script to your html.add this line <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> or add your jquery file. Commented Jun 23, 2015 at 5:38
  • You should at least see browser console. Commented Jun 23, 2015 at 6:28
  • im sorry what is browser console???? im actually new at these things and im unaware of most terminologies.. Commented Jun 23, 2015 at 7:31
  • check this Commented Jun 23, 2015 at 8:29

1 Answer 1

3

You have to add jquery js in your html code. you can use online jquery.

   <script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
   <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.