4
In this code below, it updates a div every 20 seconds. Only when entering the page I have to wait 20 seconds for it to appear. I would like it to appear already at the beginning, when entering the page.
<div id="latestData"><img src="img/loading3.gif" /></div>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
    $(document).ready(function () {
       setInterval(function() {
          $.get("includes/principal/contador_mapa.php", function (result) {    
              //nome da pagina com o select mysql
              $('#latestData').html(result);  // nome da DIV
          });
       }, 20000); // segundos
    });
</script>
						
I don’t know if it’s a good idea to use
setIntervalin that case. http://answall.com/questions/77764/por-que-dizem-recursividade-settimeout-%C3%A9-better-than-setinterval/77765#77765– Wallace Maxters