18

I have followed this guide on MDN.

var formData = new FormData();    
formData.append("username", "Groucho");
formData.append("accountnum", 123456);
console.log(formData);

Why is formData empty?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
cola
  • 12,198
  • 36
  • 105
  • 165

1 Answers1

17

Their is way to access FormData

var formData = new FormData();

formData.append("username", "Groucho");
formData.append("accountnum", 123456);

console.log(formData.get("username"));
console.log(formData.get("accountnum"));
Parth Trivedi
  • 3,802
  • 1
  • 20
  • 40
  • 2
    Note that `FormData.get()` only works in Firefox and Opera. – Rory McCrossan Dec 08 '15 at 11:36
  • 1
    Are you sure? I get `Uncaught TypeError: formData.get is not a function` when I run it in Chrome 47: http://jsfiddle.net/pLyhnkw5/. Also [MDN](https://developer.mozilla.org/en-US/docs/Web/API/FormData/get) says that this has no support in Chrome. – Rory McCrossan Dec 08 '15 at 11:38
  • Yes correct FormData() works but get function not working. – Parth Trivedi Dec 08 '15 at 11:39