summaryrefslogtreecommitdiff
path: root/modules/lijst/lijst.html
diff options
context:
space:
mode:
Diffstat (limited to 'modules/lijst/lijst.html')
-rw-r--r--modules/lijst/lijst.html22
1 files changed, 14 insertions, 8 deletions
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() {
</ol>
<input type="text" id="text" placeholder="New item text">
<input type="button" onclick="addItem()" value="Add item"><br>
-<br>
-<input type="button" onclick="removeItem()" value="Remove top item">
</body>
</html>