【问题标题】:Error saving data from Datatable to MySQL database将数据从 Datatable 保存到 MySQL 数据库时出错
【发布时间】:2018-05-17 18:20:28
【问题描述】:
//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, 
            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>');
            $('#action').attr('disabled', false);
            $('#item_data').DataTable().ajax.reload();                
        },
        error : function () {
            $('<div>').html('Found an error!');
        }
    })
});

这是我的 java 代码,我正在尝试调用一个 php 页面并将所有数据保存在我的数据库中。我收到一个错误:

TypeError:在未实现接口 HTMLTableRowElement 的对象上调用了“insertCell”。

当我将数据插入表“it_det”时发生这种情况

看图:

如果我不向表中插入新行,我就不会出错! 那有什么问题?为什么会出现这个错误???

【问题讨论】:

    标签: javascript php jquery ajax datatable


    【解决方案1】:

    我找到了将“processData”键更改为 false 的解决方案

    $.ajax({
            processData: false, //The default value of ProcessData is true so changing in false I don't get any error.
            url:'item_action.php',
            method:"POST",
    

    【讨论】:

      猜你喜欢
      • 2015-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-02
      • 2021-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多