=================================================================== RCS file: /cvs/cvs/draft/form.min.js,v retrieving revision 1.87 retrieving revision 1.98 diff -u -p -r1.87 -r1.98 --- draft/form.min.js 2024/03/31 16:13:39 1.87 +++ draft/form.min.js 2024/03/31 17:14:06 1.98 @@ -45,7 +45,7 @@ async function sendData() { } else { var fcon = document.querySelectorAll(".wpcf7-form-control"); - info.textContent="Please wait..." + info.textContent="Verifying..." fcon.forEach((f) => { f.disabled=true; l=f; @@ -58,32 +58,28 @@ async function sendData() { 'response-field': false, sitekey: '0x4AAAAAAAVpXFEy152AON1L', 'error-callback': function(e) { - info.textContent="Cloudflare Turnstile verification error. Try again later." + info.textContent="Verification error. Try again later."; + turnstile.remove(); }, callback: function(token) { const data = JSON.stringify({"add": mail, "sub": subj, "msg": mess, "tok": token}); - info.textContent="Sending..."; + turnstile.remove(); + info.textContent+="Sending..."; +// console.log(data); + fetch("/feedbk/", { + headers: { "Content-Type": "application/json" }, + credentials: "same-origin", + mode: "same-origin", + method: "post", + body: data + }) + .then(response => response.json()) + .then(json => info.textContent=parseString(json['msg'])) } }); }); - info.textContent="Fin"; - turnstile.remove(); }; } - -// ============================================================= // -/*fetch("/feedbk/", { - credentials: "same-origin", - mode: "same-origin", - method: "post", - headers: { "Content-Type": "application/json" }, - body: dataToSend -}) - .then(response => response.json()) - .then(json => ii.textContent=json['msg']) - - turnstile.close(); - }*/ form.addEventListener("submit", (event) => { event.preventDefault();