diff options
Diffstat (limited to 'view')
-rw-r--r-- | view/static/ceres.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/view/static/ceres.js b/view/static/ceres.js index acb52a4..a6b5591 100644 --- a/view/static/ceres.js +++ b/view/static/ceres.js @@ -1,9 +1,9 @@ var forms = document.querySelectorAll('form'); forms.forEach(form => { - form.addEventListener('submit', sendFormAsJson); + form.addEventListener('submit', updateFormData); }); -function sendFormAsJson(event) { +function updateFormData(event) { event.preventDefault(); const form = event.target; @@ -30,3 +30,20 @@ function sendFormAsJson(event) { console.error('Network error:', error); }); } + +function del(url) { + fetch(url, {method: 'DELETE'}) + .then(response => { + if (response.ok) { + console.log('Deletion successfully'); + } else { + console.error('Deletion failed'); + } + if (response.redirected) { + window.location.href = response.url; + } + }) + .catch(error => { + console.error('Network error:', error); + }); +} |