1

Trying to construct a new FormData object to send as part of an AJAX request, however constructing the object with a jQuery selected object remains empty.

enter image description here

Am I doing something wrong?

Aesthete
  • 18,622
  • 6
  • 36
  • 45

1 Answers1

3

It's not empty, you just can't see it

FormData is created only for sending keyed data, not fot retrieving it

Community
  • 1
  • 1
vladkras
  • 16,483
  • 4
  • 45
  • 55
  • Thanks, that's interesting. Problem is when I used `submit` to send the form, I recieved data with `'image'` as the key. When I POST with jquery and include the `new FormData(...)` object as data, I don't get that key. – Aesthete Nov 14 '14 at 04:11
  • @Aesthete did you try to _set the right options_: `processData: false` and `contentType: false` as mentioned in last example in [article I provided](https://developer.mozilla.org/en-US/docs/Web/Guide/Using_FormData_Objects#Sending_files_using_a_FormData_object) in my answer? – vladkras Nov 14 '14 at 05:23
  • Yep, had all those values setup. I've gone with another solution, but your answer is still correct. Now I know why it appears empty. – Aesthete Nov 14 '14 at 05:24
  • In Chrome and Firefox you can use this:[code] for (var pair of frmData.entries()) { console.log(pair[0]+ ', ' + pair[1]); }[/code] – Pianoman Aug 25 '17 at 18:29