fix: proper success/error response for all SPBU save endpoints and fix jalan/parsil handlers

This commit is contained in:
2026-06-11 02:25:54 +07:00
parent d583efc322
commit b486269a93
4 changed files with 60 additions and 25 deletions
+28 -2
View File
@@ -1092,7 +1092,20 @@ function openJalanPopup(layer, geojson, panjang) {
if (!form) return;
form.addEventListener('submit', function(ev) {
ev.preventDefault();
fetch('simpan_jalan.php', { method:'POST', body:new FormData(this) }).then(() => location.reload());
fetch('simpan_jalan.php', { method:'POST', body:new FormData(this) })
.then(r => r.text())
.then(res => {
if (res.trim() === 'success') {
map.closePopup();
cancelPendingShape(false);
setMode(null);
loadData();
showToast('Jalan berhasil ditambahkan!', 'success');
} else {
showToast('Gagal simpan jalan: ' + res, 'error');
}
})
.catch(() => showToast('Error koneksi ke server.', 'error'));
});
}, 50);
}
@@ -1105,7 +1118,20 @@ function openParsilPopup(layer, geojson, luas) {
if (!form) return;
form.addEventListener('submit', function(ev) {
ev.preventDefault();
fetch('simpan_parsil.php', { method:'POST', body:new FormData(this) }).then(() => location.reload());
fetch('simpan_parsil.php', { method:'POST', body:new FormData(this) })
.then(r => r.text())
.then(res => {
if (res.trim() === 'success') {
map.closePopup();
cancelPendingShape(false);
setMode(null);
loadData();
showToast('Parsil berhasil ditambahkan!', 'success');
} else {
showToast('Gagal simpan parsil: ' + res, 'error');
}
})
.catch(() => showToast('Error koneksi ke server.', 'error'));
});
}, 50);
}