how to get data from form js code example
Example 1: javascript form data
var formData = new FormData();
fromData.append('name','value');
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);
})
});