Subir archivos a "js"
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
const idPartida = $("body").data("id-partida");
|
||||||
|
|
||||||
|
comprobarEstadoPartida(idPartida);
|
||||||
|
|
||||||
|
const intervalo = setInterval(function () {
|
||||||
|
comprobarEstadoPartida(idPartida, intervalo);
|
||||||
|
}, 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
function comprobarEstadoPartida(idPartida, intervalo = null) {
|
||||||
|
$.ajax({
|
||||||
|
url: "controladores/ControladorResultados.php",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
orden: "comprobarEstado",
|
||||||
|
idPartida: idPartida
|
||||||
|
},
|
||||||
|
success: function (respuesta) {
|
||||||
|
if (respuesta.error) {
|
||||||
|
console.error("Error:", respuesta.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (respuesta.terminada) {
|
||||||
|
if (intervalo !== null) clearInterval(intervalo);
|
||||||
|
|
||||||
|
$("#pantalla-espera").fadeOut(400, function() {
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
console.log("Error de comunicación con el controlador.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user