2017-09-14 51 views
1

我試圖收集我的窗體的所有數據:JQ FormData幫助。無法收集數據

我創建擾流板形式:

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>\ 
'; 

,我想獲得的onclick:

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

它爲什麼不起作用?它不收集所有輸入數據...

回答

0

你必須使用append方法FORMDATA

,並預計兩個參數append(nameData, valueData)

如何使用 FormData