www.federated.computer/public/js/form-handler.min.js
2023-09-24 17:51:06 -06:00

1 line
765 B
JavaScript

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