Last active
July 19, 2020 02:53
-
-
Save paulaleite/1ee5a1d0c56d4f9c9e73c3ca92965e1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleFormSubmit = event => { | |
event.preventDefault(); | |
const form = document.getElementById('contactForm'); // 1 | |
const formData = new FormData(form).entries(); // 2 | |
var xmlhttp = new XMLHttpRequest(); // 3 | |
var url = "https://<URL_website>/<caminho>"; // 4 | |
xmlhttp.open("POST", url); // 5 | |
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); // 6 | |
xmlhttp.send(JSON.stringify(Object.fromEntries(formData))); // 7 | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment