I cannot Ajax post selected row data to server

I cannot Ajax post selected row data to server

poeziafreepoeziafree Posts: 35Questions: 11Answers: 0
edited September 2021 in DataTables

Hello,

I am trying to implement to checkbox selection of rows. As at least one row is selected the delete button gets active, now what I need is to by clicking the delete button, send an array of selected rows' data (only the first cell data from each selected row) to the PHP server so that the data is deleted from MySQL as well.

The current code looks like this:

`var table = $('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "scripts/server_processing.php",
dom: 'Bfrtip',
buttons: [
{
text: 'Reload table',
action: function () {
table.ajax.reload();
}
},
{
extend: 'selected',
text: 'Log selected data',
action: function ( e, dt, button, config ) {
alert( dt.rows( { selected: true } ).indexes().length +' row(s) selected' );
var rowData = table.rows('.selected').data().toArray();

            var mda = table.cells('.selected', 0).data();



        }
    }

    ],
  'columnDefs': [
     {
        'targets': 0,
        'checkboxes': {
           'selectRow': true
        }
     }
  ],
  'select': {
     'style': 'multi',
     'selector': 'td:first-child'
  },     
  'order': [[1, 'asc']]
} );`
Sign In or Register to comment.