I want to list results of a PHP page using jquery, which is updated every 3 seconds, but I can not. The code I'm using is:
<div id="listar"></div>
<script src="assets/js/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
function mostrar(){
$(document).ready(function(){
$.ajax({
type:'post',
dataType: 'json',
url: 'atualizar.php',
success: function(dados){
$('#listar').append(dados[0]);
}
});
});
}
//setInterval(function(){ mostrar; }, 3000);
setInterval(mostrar, 3000);
</script>
As an example, I put the PHP code below:
$ver = "teste";
echo json_decode($ver);
The problem is in Jquery and not PHP;)