fix duplicate
This commit is contained in:
@@ -434,10 +434,17 @@ function duplicateLastMonth(lastMonthDate, owner) {
|
|||||||
formData.append("owner", owner);
|
formData.append("owner", owner);
|
||||||
|
|
||||||
fetch("/modules/budget/includes/api/save-savings.php", { method: "POST", body: formData })
|
fetch("/modules/budget/includes/api/save-savings.php", { method: "POST", body: formData })
|
||||||
.then(r => r.json())
|
.then(async r => {
|
||||||
.then(d => {
|
const text = await r.text(); // On lit en texte brut d'abord
|
||||||
if (d.success) window.location.reload();
|
try {
|
||||||
else alert("Erreur serveur : " + (d.error || "Inconnue"));
|
const d = JSON.parse(text); // On essaie de parser en JSON
|
||||||
|
if (d.success) window.location.reload();
|
||||||
|
else alert("Erreur serveur : " + (d.error || "Inconnue"));
|
||||||
|
} catch(e) {
|
||||||
|
// Si ça plante (HTML, redirection, erreur PHP masquée), on force le rechargement
|
||||||
|
console.log("Avertissement : La réponse serveur n'était pas du JSON. Rechargement...");
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user