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);
}
?>
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);
}
?>
But how can i put that in php?
u said u have ajax, so you can make ajax call (which calls php file) and update div at every 5 seconds
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 :(
http://stackoverflow.com/questions/220767/auto-refreshing-div-with-jquery
This is sample code.
You need to include jquery in your scirpt than you can follow above link
another example
http://www.9lessons.info/2009/07/auto-load-refresh-every-10-seconds-with.html
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.