Good afternoon Friends.
My question is the following, I have a script that basically reads a .log in real time and shows it on the screen, but the question is that it starts with the DOM, I'd like it to start only from the click of the button , could you 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>