Auto refresh div using jquery


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <html>
  2. <head>
  3. <!-- For ease i'm just using a JQuery version hosted by JQuery- you can download any version and link to it locally -->
  4. <script src="jquery-1.3.2.min.js"></script>
  5.  
  6. <script>
  7. $(document).ready(function() {
  8. $("#responsecontainer").load("response.php");
  9. var refreshId = setInterval(function() {
  10. $("#responsecontainer").load('response.php?randval='+ Math.random());
  11. }, 9000);
  12. });
  13. </script>
  14. </head>
  15. <body>
  16.  
  17. <div id="responsecontainer">
  18. </div>
  19. </body>
  20.  
  21. --------------------------------
  22.  
  23. response.php :
  24.  
  25. <? echo rand(); ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.