Reputation: 9221
<?php include("news.php"); ?>
Hello, I include a news.php
in my main page index.php
. I want to refresh the news.php
every 30 seconds, but not refresh the main page index.php
, How to partial refresh a include php page? Thanks.
Upvotes: 3
Views: 25445
Reputation: 1
I've been searching for something similar and it's taken a while but I think this might work:
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
setInterval(function() {
$("#screen").load('news.php')
}, 2000);
});
</script>
Upvotes: 0
Reputation: 1
Another way to refresh an include (Valid only if the include only contains variables and their values):
<?php
$config = file_get_contents("news.php");
$config = str_replace("<?php", "", $config);
$config = str_replace("?>", "", $config);
eval($config);
?>
Upvotes: -2