Affiliates


PHP Chat with AJAX



PHP chat is a most common as these days with the help of AJAX  I share to you my basic scripts with autorefresh

at first you need to have localhost server or any web site hosting that supports php.

these are my scripts

Create file for your chat display

ex.
response.php
code:
put inside the data to be displayed

second file
index.php

code:
  1. <html>
  2. <head>
  3. <script src="http://code.jquery.com/jquery-latest.js"></script>
  4. <script>
  5. $(document).ready(function() {
  6. $("#responsecontainer").load("response.php");
  7. var refreshId = setInterval(function() {
  8. $("#responsecontainer").load('response.php?randval='+ Math.random());
  9. }, 1000);
  10. $.ajaxSetup({ cache: false });
  11. });
  12. </script>
  13. </head>
  14. <body>
  15. <iframe src="main.php" width="100%" height="25%" ></iframe>
  16. <div id="responsecontainer">
  17. </div>
  18. </body>
  19. </html>


REASON:

each text on response with automatically displayed as it refresh without window loading.

Comments

Popular posts from this blog

Fixed by using cmd: USB drive unusable, unformattable, and reporting 0 bytes capacity

A Love of a brother