0

I have a page on which I want to include another php page and update this page every 1 second. I try to include it using javascript and .load but it doesn't work. A solution doesn't have to involve using javascript and php, I'm just looking for a way to show who's online on my forum.

test1.php

<html>
<head>
    <script>
        setInterval(function () {
            $("#show-time").load("test2.php");

        }, 1000);
    </script>
</head>
<body>
    <p id="show-time"></p>
</body>
</html>

test2.php

<?php
echo time();
The Coding Wombat
  • 805
  • 1
  • 10
  • 29
  • Well you are trying to use jQuery without including the jQuery library, your code should be throwing up errors in the javascript console – Patrick Evans Sep 19 '15 at 00:11
  • Have you checked the docs? There's an example of exactly what you're trying to achieve here: http://api.jquery.com/load/ – Ragdata Sep 19 '15 at 00:13
  • Although this is probebly not the way to update who's online on your website, your code works perfectly fine except for the fact that you didn't include the jQuery library. – icecub Sep 19 '15 at 00:16
  • thank you, I didn't know about the jQuery library not working by default – The Coding Wombat Sep 19 '15 at 00:18

0 Answers0