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.phpcode:
put inside the data to be displayed
second file
index.php
code:
- <html>
- <head>
- <script src="http://code.jquery.com/jquery-latest.js"></script>
- <script>
- $(document).ready(function() {
- $("#responsecontainer").load("response.php");
- var refreshId = setInterval(function() {
- $("#responsecontainer").load('response.php?randval='+ Math.random());
- }, 1000);
- $.ajaxSetup({ cache: false });
- });
- </script>
- </head>
- <body>
- <iframe src="main.php" width="100%" height="25%" ></iframe>
- <div id="responsecontainer">
- </div>
- </body>
- </html>
REASON:
each text on response with automatically displayed as it refresh without window loading.
Comments
Post a Comment