gpt4 book ai didi

javascript - 类型错误 : 'append' called on an object that does not implement interface FormData

转载 作者:行者123 更新时间:2023-11-29 19:05:50 26 4
gpt4 key购买 nike

$(document).on('submit','#form_pem', function(event){
event.preventDefault();
var kodebayar = $('#kodebayar').val();
var nama = $('#nama').val;
var harga = $('#harga').val;
var postData = new FormData(this);

if(kodebayar != '' && nama != '' && harga != ''){
$.ajax({
url:"<?=site_url('bpem/user_action')?>",
method:"POST",
data:postData,
contentType:false,
proccessData:false,
success: function(data)
{
alert(data);
$('#form_pem')[0].reset();
$('#modalpem').modal('hide');
dataTable.ajax.reload();
}

});

}
else{
alert("Silahkan isikan semua data!");
}
});

这是我的JS

<div class="modal fade text-xs-left" id="modalpem" tabindex="-1" role="dialog" aria-labelledby="myModalLabel35" aria-hidden="true">
<div class="modal-dialog modal-sm">
<form method= "post" id="form_pem">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h3 class="modal-title text-xs-center">Tambah Biaya Pembayaran</h3>
</div>
<div class="modal-body">
<fieldset class="form-group floating-label-form-group">
<label for="Kode">Kode <span class="required">*</span></label>
<input type="text" class="form-control" name="kodebayar" id="kodebayar" placeholder="Kode Pembayaran">
</fieldset>
<fieldset class="form-group floating-label-form-group">
<label for="nama">Nama <span class="required">*</span></label>
<input type="text" class="form-control" name="nama" id="nama" placeholder="Nama Pembayaran">
</fieldset>
<fieldset class="form-group floating-label-form-group">
<label for="projectinput7">Biaya Perbulan <span class="required">*</span></label>
<div class="input-group">
<span class="input-group-addon">Rp.</span>
<input type="number" class="form-control" placeholder="Biaya Perbulan" aria-label="Amount (to the nearest dollar)" name="harga" id="harga">
<span class="input-group-addon">.00</span>
</div>
</fieldset>
</div>
<div class="modal-footer">
<input type="reset" class="btn btn-grey" value="Bersihkan">
<input type="submit" class="btn btn-warning" name="action" id="action" value="Tambah">
</div>
</div>
</form>
</div>

</div>

这是 View 。但是我得到了一个错误

TypeError:在未实现接口(interface) FormData 的对象上调用“append”。

我是不是忘记补充什么了?我应该怎么办?谢谢你的帮助

最佳答案

需要更正打字错误:)

proccessData:false

应该是

processData: false

为避免 FormData 错误,请确保 ajax 选项必须类似于

$.ajax({
url : "url",
type: "POST",
data : postData,
processData: false,
contentType: false,
success:function(data, textStatus, jqXHR){
//
},
error: function(jqXHR, textStatus, errorThrown){
//if fails
}
});

关于javascript - 类型错误 : 'append' called on an object that does not implement interface FormData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42923298/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com