Skip to content

Instantly share code, notes, and snippets.

@anova
Created September 30, 2022 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anova/c837481e5c30a463c7ff95a69339f4ff to your computer and use it in GitHub Desktop.
Save anova/c837481e5c30a463c7ff95a69339f4ff to your computer and use it in GitHub Desktop.
Send POST form data, serialized by FormData with fetch
const the_form = document.getElementById('the_form');
const formData = new FormData(the_form);
fetch('the-handler.php',{
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
console.log('data is:', data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment