Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
330 B
2
Indexable
Never
const form = document.querySelector('form');
form.addEventListener('submit', (event) => {
  event.preventDefault();
  const formData = new FormData(form);
  fetch(form.action, {
    method: 'POST',
    body: formData
  })
  .then(response => {
    // handle the response
  })
  .catch(error => {
    // handle the error
  });
});