datatables 1.10 add.row()在ajax响应中不起作用

use*_*659 6 ajax jquery datatables jquery-datatables

使用带有dom创建表的数据表1.10.我试图在ajax响应中添加一行新数据,但没有任何反应.相同的代码本身(没有ajax)工作得非常好.是的,response.success返回'true'.

//这可以工作并将新行添加到表中

$('#test').on('click', function () {
    dt.row.add( [
        'td0',
        'td1',
        'td2',
        'td3'
    ] ).draw();
});
Run Code Online (Sandbox Code Playgroud)

//相同的代码在ajax响应中不起作用...

$('#dtCreate').on('click', function () {

    $.ajax({
        type: 'post',
        url: '/test/process/p_db_create.php'
    }).done(function (response) {

        //double check response
        console.log(response);

        if (response.success)
        {
            //add the row since this is not serverside
            dt.row.add( [
                'td0',
                'td1',
                'td2',
                'td3'
            ] ).draw();
                ...more code below...
Run Code Online (Sandbox Code Playgroud)

Cra*_*aig 0

调用 add().draw(); 后 通过调用 -- dt.dataTable() 重新初始化表;