fix: proper success/error response for all SPBU save endpoints and fix jalan/parsil handlers
This commit is contained in:
+28
-2
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user