Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FormData append doesn't work

In jQuery code,

var formData = new FormData($('#content-submit')[0]);
        formData.append("Title", $("input[name=Title]").val());
        formData.append("Url", $("input[name=Url]").val());
        formData.append("Content", $("textarea[name=Content]").text());
        formData.append("Genre", $("input[name=Genre]").val());
        formData.append("File", $("input[name=File]")[0].files[0]);
        console.log(formData);

But console.log says

FormData {}

So I think that FormData append method doesn't work. Are there other things that I should do?

like image 754
HyeonJunOh Avatar asked May 19 '16 04:05

HyeonJunOh


1 Answers

FormData can't be inspected from the web developer console. You can only use them to create key value pairs to be sent.

If you want to debug it, you may do this,

for (var p of formData) {
  console.log(p);
}
like image 62
choz Avatar answered Sep 29 '22 19:09

choz