From cab886e5ab02ffc58ce14aa73b7f30e4859fad44 Mon Sep 17 00:00:00 2001 From: Steven Tracey Date: Thu, 27 Apr 2023 13:50:51 -0400 Subject: [PATCH] Fix data consistancy in submitForm function --- index.html | 18 ++++-------- script.js | 78 ++++++++++++++++++++++++++++++++++++++++---------- stylesheet.css | 2 +- 3 files changed, 70 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index a95569b..b786038 100644 --- a/index.html +++ b/index.html @@ -42,7 +42,9 @@

Current Backend Url:

** DEV ENV** - VCard Creator - ** DEV ENV **

-
+ + +
@@ -57,15 +59,7 @@
- +
@@ -83,8 +77,8 @@
- - + +
diff --git a/script.js b/script.js index 5ce667c..3624cf1 100644 --- a/script.js +++ b/script.js @@ -12,36 +12,69 @@ function handleCheckbox() { } } -function submitForm() { +let backendUrl = "http://127.0.0.1:8090" +let locations = JSON.parse("{}"); +function submitForm() { + fetchWithTimeout(backendUrl + "/", { + timeout: 5000, + method: 'POST', + mode: 'cors', + headers: { + 'Accept': 'image/png', + 'Content-Type': 'application/json' + }, + body: JSON.stringify( + "{" + + "\"name\":\"" + document.getElementById("full_name").value + "\"," + + "\"title\":\"" + document.getElementById("title").value + "\"," + + "\"email\":\"" + document.getElementById("email").value + "\"," + + "\"location\":\"" + document.getElementById("location").value + "\"," + + "\"extension\":\"" + document.getElementById("extension").value + "\"," + + "\"hasExtension\":\"" + document.getElementById("hasExtension").value + "\"," + + "\"cellNumber\":\"" + document.getElementById("cellNumber").value + "\"," + + "\"hasCell\":\"" + document.getElementById("hasCell").value + "\"" + + "}" + ) + }).then(response => { + console.log(response); + }); } + function getLocations() { - //TODO use (backend)/data/locations and do `document.getElementById("location").innerHtml` - //TODO and add