I am writing a system that should update two divs, as much as possible, in real time. The way I found it is as follows, using AJAX:
function actualizarDatos(){
$.ajax({
type: 'POST',
cache: false,
async:true,
url: 'lista_datos1.php',
success: function(respuesta) {
$('#ListaDatos1').html(respuesta);
}
});
$.ajax({
type: 'POST',
cache: false,
async:true,
url: 'lista_datos2.php',
success: function(respuesta) {
$('#ListaDatos2').html(respuesta);
}
});
}
setInterval( function(){
actualizarDatos();
},3000)//Actualizo cada 3 segundos
I have already noticed some inconsistencies when using it and this web application will be executed by several simultaneous users.
Is what I'm doing right? Do you suggest a better way to do it?
I appreciate your comments, regards!