I have this php page /var/www/oggi1ora.php.
First I need to execute the page /usr/local/bin/oggi1ora.php to generate chart.
Every 5 seconds the php script is executing correctly, but image in the page is not refreshing... how can i resolve this?
I need execute every 5 secs /usr/local/bin/oggi1ora.php. The script generate image stored in /var/www/grafici/oggi1ora.png.
<div class="result">
<?php exec('php -q /usr/local/bin/oggi1ora.php'); ?>
</div>
<div class="oggi1ora">
<html>
<body>
<img src="grafici/oggi1ora.png" id="oggi1ora" border="0" />
</body>
</html>
</div>
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script>
function refresh_div() {
jQuery.ajax({
url:'oggi1ora.php',
type:'POST',
success:function(results) {
jQuery(".result").html(results);
}
});
}
t = setInterval(refresh_div,5000);
</script>
This is new /var/www/oggi1ora.php
<div class="result">
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
include('/usr/local/bin/oggi1ora.php');
?>
</div>
<div class="oggi1ora">
<html>
<img src="grafici/oggi1ora.png" id="oggi1ora" border="0" />
</html>
</div>
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script>
function refresh_div() {
var d = new Date().getTime();
jQuery.ajax({
url:'oggi1ora.php?ts=' + d,
type:'POST',
success:function(results) {
$("#oggi1ora").attr("src", "grafici/oggi1ora.png?ts=" + d);
}
});
}
t = setInterval(refresh_div,5000);
</script>
<div>tags outside of the<body>... Probably not related to your issue, but still...