I have a step-by-step form of which with each step saved in the information database. In the last step I bring the information saved as follows with jquery:
<script type="text/javascript">
function mostrar(){
$(document).ready(function(){
$.ajax({
type:'post',
dataType: 'json',
url: 'atualizar.php',
success: function(dados){
for(var i=0;dados.length>i;i++){
$('#listar').append(dados[0]);
$('#listar').append(dados[i].id+'</td><td>'+dados[i].nome+'</td><td>'+dados[i].email+'</td></tr>');
}
console.log(dados);
}
});
});
}
setInterval(mostrar, 2000);
</script>
It is working perfectly, but in this case I am updating the div for 2 seconds and would like to know if it is possible to update only when accessing the div in the last step. The HTML looks like this:
<fieldset>
<!-- Última etapa do step-by-step -->
<h4>Confirme seus dados:</h4>
<div id="listar"></div>
<form role="form" action="" method="post" id="contact-form">
<div class="f1-buttons">
<button type="button" class="btn btn-previous">Alterar</button>
<button type="button" class="btn btn-primary">Finalizar</button>
</div>
</form>
</fieldset>