javascript data from a form code example
Example 1: javascript form data
var formData = new FormData();
Example 2: js get form data
document.addEventListener('submit', function (event) {
event.preventDefault();
fetch('https://xxx.xxx', {
method: 'POST',
body: new FormData(event.target),
}).then(function (response) {
if (response.ok) {
return response.json();
}
return Promise.reject(response);
}).then(function (data) {
console.log(data);
})
});