<form class="form" id="formElem">
<input type="text" name="name" placeholder="Name">
<input type="phone" name="phone" placeholder="Phone">
<button type="submit">Отправить</button>
</form>
const form = document.querySelector('.form'),
inputs = document.querySelectorAll('input'),
btn = document.querySelector('button');
form.addEventListener('submit', (e) => {
e.preventDefault();
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://jsonplaceholder.typicode.com/posts');
const formData = new FormData(form);
xhr.send(formData);
xhr.addEventListener('load', () => {
console.log(xhr.status);
console.log(xhr.response);
});
});
Статус Http 201, почему не отправляются данные с формы?