Question: DataTable click function reload data with button Not Working

Question

DataTable click function reload data with button Not Working

Answers 0
Added at 2016-12-25 22:12
Tags
Question

I have problem with click function reload datatable data. I have javascript DataTable like this

    var table = $('#CTable').DataTable({
        processing: true,
        serverSide: true,
        destroy: true,
        ajax: 'getData',
        columns: [
            { data: 'user_id'},
            { data: null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                 $(nTd).html("<div class='ui-group-buttons'><button id='"+oData.report_id+"' onClick='reject(this.id)' type='button' class='btn btn-danger btn-xs yuhu'>Reject</button></div>");
            }},
        ]
    });

I need to create some function with ajax post, and if success function reload datatable data. I have code to post ajax data with button generated by fnCreatedCell and working perfect, but if I created with success function table.clear().draw(); not working

This is my javascript function

function reject(clicked_id)
    {
        $.ajax({
              url: "reject",
              type: 'post',
              data: {'_token':Token, 'reportid': clicked_id},
              success: function(){
                  table.clear().draw();
              },
            });
    }

Please help me to create correct function to post data with ajax and if success reload datatable data. Thank You

Answers to

DataTable click function reload data with button Not Working

Source Show
◀ Wstecz