diff --git a/index.html b/index.html index 1f037a2..8bb6a9b 100644 --- a/index.html +++ b/index.html @@ -4,9 +4,9 @@ - - - + + +
diff --git a/js/data.js b/js/data.js index f00825a..36bb501 100644 --- a/js/data.js +++ b/js/data.js @@ -40,3 +40,21 @@ var table = $('#table-list').DataTable({ }, ], }) + +function buttonAdd() { + var name = document.getElementById("form-add-name" ).value; + var phone = document.getElementById("form-add-phone" ).value; + var url = "http://localhost:11000/api/create"; + var payload = { + "name" : name, + "phone" : phone + }; + sendHttpRequest(url, "POST", payload, function (error, response) { + if (error) console.error("Error:", error); + else { + table.ajax.reload(null, false); // false means keep the current page + console.log("JSON Response:", response); + } + }, "application/json"); +} +