0
Boa Tarde Amigos.
My question is this, I have a script that keeps reading one. log basically in real time and shows it on screen, but the point is that it starts with the DOM, I would like it to start only from the click on the button, could help me ??
<?php
if (isset($_GET['ajax'])) {
$sessionID = 'log'.$_GET['s'];
session_id($sessionID);
session_start();
$handle = fopen('/\\cordas\instance-8480\log\server.log', 'r');
if (isset($_SESSION['offset'])) {
$data = stream_get_contents($handle, -1, $_SESSION['offset']);
echo nl2br($data);
} else {
fseek($handle, 0, SEEK_END);
}
$_SESSION['offset'] = ftell($handle);
exit();
}
$randomSession = rand();
?>
<script>
$(document).ready(function( ) {
$.repeat(1000, function() {
$.get('automacao_tela.php?ajax&s=<?=$randomSession;?>', function(data) {
$('#tail').append(data);
});
});
});
</script>
<form action="?automacao=ok" method="POST">
<button type="submit" class="log-btn" >INICIAR PROCESSO</button>
</form>
<div id="tail" class="widget-stats-list-log">
Starting up...
</div>
Thank you for the friendly reply, but it still hasn’t worked that way.
– Matheus