=================================================================== RCS file: /cvs/cvs/draft/form.min.js,v retrieving revision 1.41 retrieving revision 1.67 diff -u -p -r1.41 -r1.67 --- draft/form.min.js 2024/03/28 20:33:14 1.41 +++ draft/form.min.js 2024/03/30 17:57:24 1.67 @@ -26,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; @@ -42,29 +42,25 @@ async function sendData() { turnstile.remove(); }, callback: function(token) { - ii.textContent="Sent"; - console.log(`Challenge Success ${token}`); -/* --------------------- */ -const ob = {mail: $em, sub: $su, msg: $ms, id: $token }; -var data="", - status="", - feed=JSON.stringify(ob); -$.post("/feedbk/", feed, function(data, status){ - console.log("Data: " + data + "\nStatus: " + status); -}); -/* --------------------- */ -//var re=""; -//re=fetch('/feedbk/', { -// method: 'POST', -// headers: { -// 'Accept': 'application/json', -// 'Content-Type': 'application/json' -// }, -// body: JSON.stringify({ "cfem": "a@b.ru", "cfsu" : "subject", "cfme" : "message", "cfto" : "token" }) -//}); - // .then(response => response.json()) - // .then(response => console.log(JSON.stringify(response))) -// console.log(re); + 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)) + + + + },