Files
Freedom-Loader/public/script/downloadstatus.js
MasterAcnolo bb967834f0 Loading Screen
2025-06-27 23:11:42 +02:00

30 lines
896 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const form = document.getElementById("downloadForm");
const statusDiv = document.getElementById("downloadStatus");
form.addEventListener("submit", async (e) => {
e.preventDefault(); // empêche la soumission classique (rechargement)
statusDiv.textContent = "⏳ Téléchargement en cours...";
const formData = new FormData(form);
const params = new URLSearchParams(formData);
try {
const res = await fetch("/download", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: params,
});
if (!res.ok) {
statusDiv.textContent = "❌ Erreur pendant le téléchargement.";
return;
}
const text = await res.text();
statusDiv.textContent = text; // affiche « Téléchargement terminé » ou autre message serveur
} catch {
statusDiv.textContent = "❌ Une erreur sest produite.";
}
});