=================================================================== RCS file: /cvs/cvs/draft/form.min.js,v retrieving revision 1.31 retrieving revision 1.67 diff -u -p -r1.31 -r1.67 --- draft/form.min.js 2024/03/28 19:50:37 1.31 +++ draft/form.min.js 2024/03/30 17:57:24 1.67 @@ -13,19 +13,6 @@ function validateMsg(msg) { return (msg.length>5); } -//async function postData() { -// const formData = new FormData(form); -// try { -// const response = await fetch("/feedbk/", { -// method: "POST", -// body: formData, -// }); -// console.log(await response.json()); -// } catch (e) { -// console.error(e); -// } -//} - async function sendData() { var er = 0; em = document.getElementById("cfem").value, @@ -39,7 +26,7 @@ async function sendData() { ii.textContent="One or more fields have an error. Please check and try again."; } else { var fc = document.querySelectorAll(".wpcf7-form-control"); - ii.textContent="All good."; + ii.textContent="Checking..."; fc.forEach((f) => { f.disabled=true; l=f; @@ -55,14 +42,24 @@ async function sendData() { turnstile.remove(); }, callback: function(token) { - ii.textContent="Sent"; - console.log(`Challenge Success ${token}`); -// postData(); -var data="", - status=""; -$.post("/feedbk/", token, function(data, status){ - console.log("Data: " + data + "\nStatus: " + status); -}); + const dataToSend = JSON.stringify({"add": em, "sub": su, "msg": ms, "tok": token}); + console.log(`JSON: ${dataToSend}`); + ii.textContent="Sending..."; + + + +fetch("/feedbk/", { + credentials: "same-origin", + mode: "same-origin", + method: "post", + headers: { "Content-Type": "application/json" }, + body: dataToSend +}) + .then(response => response.json()) + .then(json => console.log(json)) + + +