0

How can i reload $file with ajax or javascript each 5 seconds?

<?php
   if ('' == file_get_contents($file))
    {
      echo '<div id="shadow">Nobody has commented yet. Be the first? </div>';
    }
   else
    {
      include($file);
    }
?>

Edited by Sanchixx: a

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by urtrivedi
0

u said u have ajax, so you can make ajax call (which calls php file) and update div at every 5 seconds

0

no i don't have ajax. I've done this so fare

<?php
   if ('' == file_get_contents($file))
    {
      echo '<div id="shadow">Nobody has commented yet. Be the first? </div>';
    }
   else
    {
      // include($file);
?>

<script>
myFunction();
function myFunction()
{
setInterval(function(){<?php include($file); ?>},3000);
}
</script>
<?php
 }
?>

but it doesn't work :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.