Yeah, you can work it out with Ajax / jQuery:
Home page (index php.):
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<div id="DivSaida">
<!-- VALOR DA VARIÁVEL SERÁ MOSTRADO AQUI -->
<?php require_once("minhapagina.php"); ?>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
minhaUrl = "minhapagina.php"; // CAMINHO DA PÁGINA COM O ECHO
setInterval(function(){
$.ajax({
url: minhaUrl,
success: function( response ) {
$('#DivSaida').html( response );
}
});
}, 5000); // TEMPO PARA ATUALIZAR EM MS (milissegundos)
});
</script>
</html>
Page with the echo
of the variable (php.):
<?php
$file = file_get_contents('json.php');
$decode = json_decode($file, true);
$ultimo = end($decode);
$variavel = $ultimo['latitude'];
echo $variavel; //MOSTRA EXATAMENTE ESSE VALOR NA PÁGINA PRINCIPAL
?>
I didn’t change your exit variable, just gave a echo
!
I left some comments in the code, which I found interesting you change.
Sorry I put it in here didn’t work What do you think I’m missing
– Hemerson Prestes
I made a correction on home page. I developed within my own project and when posting, I put
scr
instead ofsrc
on the import of jQuery. Now it should work!– LipESprY
We can start a chat
– Hemerson Prestes
I really need to finish this I hope you can help me thank you very much
– Hemerson Prestes
as I do to enter
– Hemerson Prestes