Untitled

 avatar
unknown
javascript
2 years ago
330 B
5
Indexable
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
  });
});
Editor is loading...