From 2e2f642cf6144cbc84bff0094d34ab40de6a4b11 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Wed, 18 Sep 2019 17:08:15 +0200 Subject: lijst: Proper delete button --- modules/lijst/lijst.html | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'modules/lijst/lijst.html') diff --git a/modules/lijst/lijst.html b/modules/lijst/lijst.html index 0c1a3dd..b849720 100644 --- a/modules/lijst/lijst.html +++ b/modules/lijst/lijst.html @@ -11,20 +11,28 @@ function addItem() { xhr.open("POST", location.href + "/add"); xhr.responseType = "text"; xhr.onreadystatechange = function() { - if (xhr.readyState == 4 && xhr.status == 200) { - location.href = location.href; + if (xhr.readyState == 4) { + if (xhr.status == 200) { + location.href = location.href; + } else { + alert(xhr.responseText); + } } }; xhr.send(text); } -function removeItem() { +function removeItem(id) { var xhr = new XMLHttpRequest(); - xhr.open("POST", location.href + "/remove"); + xhr.open("POST", location.href + "/remove/" + id); xhr.responseType = "text"; xhr.onreadystatechange = function() { - if (xhr.readyState == 4 && xhr.status == 200) { - location.href = location.href; + if (xhr.readyState == 4) { + if (xhr.status == 200) { + location.href = location.href; + } else { + alert(xhr.responseText); + } } }; xhr.send(); @@ -40,7 +48,5 @@ function removeItem() {
-
- -- cgit v1.2.3-70-g09d2