www.federated.computer/public/js/form-handler.min.js
2023-06-20 11:02:12 -06:00

1 line
765 B
JavaScript

window.addEventListener("DOMContentLoaded",function(){var a=document.getElementById("contact-form"),c=document.getElementById("contact-form-button"),b=document.getElementById("contact-form-status");function d(){a.reset(),c.style="display: none",b.innerHTML="Thanks! Contact form is submitted successfully."}function e(){b.innerHTML="Oops! There was a problem."}a!=null&&a.addEventListener("submit",function(b){b.preventDefault();var c=new FormData(a);ajax(a.method,a.action,c,d,e)})});function ajax(b,c,d,e,f){var a=new XMLHttpRequest;a.open(b,c),a.setRequestHeader("Accept","application/json"),a.onreadystatechange=function(){if(a.readyState!==XMLHttpRequest.DONE)return;a.status===200?e(a.response,a.responseType):f(a.status,a.response,a.responseType)},a.send(d)}