0

Here's my form:

    <form id="content-add-form" role="form" name="content-add-form" enctype="multipart/form-data">

I'm trying to get form data using:

var formData = new FormData($('#content-add-form'));

But it's not working, any ideas why?

panthro
  • 22,779
  • 66
  • 183
  • 324

1 Answers1

3

Try this

var formData = new FormData($('#content-add-form')[0]);

You need to pass the actual form element - not the jQuery object containing it.

https://developer.mozilla.org/en-US/docs/Web/API/FormData

Constructor

new FormData (optional HTMLFormElement form)

As for why you can't see the data, read here: How to inspect FormData?

Working example: http://jsfiddle.net/TGzRa/

Community
  • 1
  • 1
Johan
  • 35,120
  • 54
  • 178
  • 293