我正在尝试将数据保存在我的数据库中(如下图所示)
但是我收到了这个错误:
TypeError:在没有实现接口HTMLTableRowElement的对象上调用'insertCell'
//ADDING NEW ITEM INTO THE ITEM TABLE
$(document).on('submit', '#product_form', function(event){
event.preventDefault();
//btn_action="add_pricelvl"; //Set variable to call the add new item
var valdata = $(this).serialize(); //Array with field value
var tax = $('#item_tax').val(); //checkbox tax
var taxvalue = $('#item_taxvalue').val(); //inputbox tax
var tabledets = it_det //Read the detail table
.rows()
.data();
var arr1=[];
var i=0;
//Put the datatable rows in the array
for (i=0; i<tabledets.length; i++){
arr1[i]=tabledets.rows(i).data();
}
//call ajax function and send variable to php file.
$.ajax({
url:'item_action.php',
method:"POST",
data:{
//btn_action:btn_action, I can recovery this value in PHP file
valdata:valdata,
tax:tax,
taxvalue:taxvalue,
arr1:arr1
},
success : function(data)
{
$('#product_form')[0].reset();
$('#productModal').modal('hide');
$('#alert_action').fadeIn().html('<div class="alert alert-success">'+data+'</div>');
$('#alert_action').fadeIn().html(result);
$('#action').attr('disabled', false);
$('#item_data').DataTable().ajax.reload();
},
error : function () {
$('<div>').html('Found an error!');
}
})
});
<div class="row">
<div class="col-sm-12 table-responsive">
<table id="item_pricelvl" class="table table-bordered table-striped">
<thead>
<tr>
<th>Price Level</th>
<th>Pricing Method</th>
<th>From Quantity</th>
<th>To Quantity</th>
<th>Discount Amount</th>
<th>Unit Price</th>
<th><input type="checkbox" class="checkall" /></th>
</tr>
</thead>
</table>
</div>
</div>
如何复制数组中的数据表内容以将数据保存在php文件中????我必须以不同的方式做什么?
for (i=0; i<tabledets.length; i++){
arr1[i]=tabledets.row(i).data();
}