weixin_33671935 2016-05-19 04:32 采纳率: 0%
浏览 3548

FormData追加不起作用

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?

  • 写回答

2条回答 默认 最新

  • from.. 2016-05-19 04:48
    关注

    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);
    }
    
    评论

报告相同问题?