I'm using JQuery in a PHP file to load the files of another content called 'live.php' which displays time(), but it doesn't load live. Why is this happening? It used to work.
MAIN.PHP
echo "<div id='x'></div>";
echo '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">';
echo '$(document).ready(function() {
$("#x").load("live.php");
});';
echo '</script>';
LIVE.PHP
<?php echo time();
You have missed the closing PHP tag in the
LIVE.PHP
It must be like:
<?php echo time(); ?>
You have missed the
?>
in your PHP file, so the PHP file would not work. So make sure you add?>
to yourLIVE.PHP
And for displaying live time without refreshing the page, you can use this jQuery:
This updates the page every 1 second.
You can change the
1000
to your desired limit (The 1000 stands for 1000 miliseconds)