From 7ae1b14e6e659929c5f50379547d7a8419402989 Mon Sep 17 00:00:00 2001 From: dbvictor2002 Date: Tue, 29 Sep 2026 13:19:26 +0200 Subject: [PATCH] Subir archivos a "js" --- js/resultados.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 js/resultados.js diff --git a/js/resultados.js b/js/resultados.js new file mode 100644 index 0000000..4ecd202 --- /dev/null +++ b/js/resultados.js @@ -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."); + } + }); +}