I use this little snippet to get form values:
myForm = document.forms[1];
email = myForm.elements['email'];
however, if I plan to use this with XHR 2's FormData, I have to do this:
function sendForm() {
var formData = new FormData();
formData.append('email', email);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/server', true);
xhr.onload = function(e) { ... };
xhr.send(formData);
}
is there any way to get all form data as one javascript object with which I can use FormData with?