updates to actually a working server sorta

This commit is contained in:
Chris Cochrun 2023-05-25 17:09:44 -05:00
parent 3f6fef03df
commit 9acb2b309a
2 changed files with 83 additions and 9 deletions

View file

@ -44,12 +44,13 @@
document.getElementById('warning-image').style.margin = '0';
}
if (!document.getElementById("agreement").unchecked) {
if (!document.getElementById("agreement").checked) {
document.getElementById('warning').style.visibility = 'visible';
document.getElementById('warning').style.height = '';
document.getElementById('warning').style.margin = '';
}
}
};
function submitForm(e) {
e.preventDefault();
const form = document.getElementById('form');
@ -59,11 +60,21 @@
const birthdate = new Date(data.get("birthdate"));
const age = calculate_age(birthdate);
data.append("age", age);
/* data.delete("image"); */
validate(data);
let req = new Request();
/* console.log(JSON.stringify(data)); */
fetch("http://localhost:4242/health-form", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(Object.fromEntries(data))
}).then((res) => {
console.log(res);
});
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
@ -77,8 +88,8 @@
* window.location.href = '/thankyou/'; */
}
};
xhr.open("POST", "https://n8n.tfcconnection.org/webhook-test/testy");
xhr.send(data);
/* xhr.open("POST", "http://localhost:4242/health-form"); */
/* xhr.send(data); */
console.log(data);
console.log("Hallo!");
/* window.location.replace("https://tfcconnection.org/thankyou/"); */
@ -89,7 +100,7 @@
var age_dt = new Date(diff_ms);
return Math.abs(age_dt.getUTCFullYear() - 1970);
}
};
function process() {
var covered = document.getElementById("medical-coverage").checked;