6

Using a datatables 1.10 with dom created table. I am attempting to add a new row of data within an ajax response yet nothing happens. The same code by itself (no ajax) works perfectly fine. Yes, the response.success is returning 'true'.

// this works and adds the new row to the table

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

//same code does not work within an ajax response...

$('#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...
1
  • have you ever found fix for this? I am running into the same issue. Commented Jan 19, 2016 at 11:09

2 Answers 2

1

the td should be initiated by DataTable() not dataTable(). I ran into this problem and wasted my good few hours.

Sign up to request clarification or add additional context in comments.

Comments

0

After you call add().draw(); Reinitialize the table by calling -- dt.dataTable();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.