FormData object is empty for a form with 2 input fields. formData.getAll() logs a error TypeError: Not enough arguments to FormData.getAll..
Here is my code:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
function test () {
var element = document.getElementById("invite-form");
console.log(element);
var formdata = new FormData(element)
console.log(formdata.getAll());
}
</script>
</head>
<body>
<form id="invite-form" method='POST' action=''>
<label for="email">Email...</label>
<input type="text" name="email" value="[email protected]"/>
<input type="hidden" name="csrf_token" value="random" />
<button class="btn" onclick="test()">Button</button>
</form>
</body>
</html>
I tried to populate the FormData object with the values from the form on clicking the button
getAll()method has somewhat spotty browser support, and really only works in Chrome 50+ and Firefox 39+formdata.getAll('email')