JQ FormData帮助。无法收集数据

时间:2017-09-14 21:06:25

标签: jquery

我正在尝试从表单中收集所有数据:

我用表单创建剧透:

var workerSpoiler = '\
<form id="worker_edit_'+this.id+'"\
<div class="form-inner-wrapper">\
<div class="block flex form-input-wrapper">\
<input type="text" data-id="gear-'+this.id+'" required name="name" value="'+this.name+'" placeholder="Фио" disabled>\
<label for="pas-scan" class="file-btn">Скан паспорта</label>\
<input id="pas-scan" type="file" data-id="gear-'+this.id+'" name="pas-scan" placeholder="Скан паспорта">\
</div>\
<div class="block form-input-wrapper">\
<textarea name="bibliography" data-id="gear-'+this.id+'" placeholder="Биография" disabled>'+this.bibliography+'</textarea>\
</div>\
<div class="block form-input-wrapper">\
<textarea name="history" data-id="gear-'+this.id+'" placeholder="История" disabled>'+this.history+'</textarea>\
</div>\
<div class="block form-input-wrapper">\
<input type="text" data-id="gear-'+this.id+'" name="salary" value="'+this.salary+'" placeholder="З/П" disabled>\
</div>\
<a href="javascript:delete_worker('+this.id+');"><i class="fa fa-trash-o" aria-hidden="true"></i></a>\
<a href="javascript:toggle_lock('+this.id+');"><i class="fa fa-cog" aria-hidden="true"></i></a>\
</form>\
</div>\
';

我正试图点击:

var formdata = new FormData($("#worker_edit_"+id)[0]);

为什么不起作用?它不收集所有输入数据......

1 个答案:

答案 0 :(得分:0)

您必须使用append方法formData

它预计有两个参数append(nameData, valueData)

如何使用 FormData