Can you show us your select in HTML?
Jun 1, 2019
6
Level 8
Datatable draw not updating post variable
I'm using Yajra Datatables, I have a select that returns 0,1 or 2 and depending on that the datatable is populated. My problem is when changing the selection the "type" variable still the one on the first selection. In other words the type still 0 regardless of what was selected. The alert that i have in the change, shows the selection chaging, but the draw has the old data:
$(document).ready(function(){
var batchesTable = $('#batches').DataTable({
processing: true,
serverSide: true,
ajax: {
url: '/getBatches',
type: 'post',
data: {
_token: "{{csrf_token()}}",
type: $("#type").val()
}
},
columns:[
{data: 'id', name: 'id'},
{data: 'name', name: 'name'},
{data: 'debit', name: 'debit'},
{data: 'credit', name: 'credit'},
{data: 'updated', name: 'updated'},
{data: 'posting', name: 'posting'},
{data: 'action', name: 'action'}
]
});
$("#type").change(function(){
alert($("#type").val());
batchesTable.draw();
});
})
Please or to participate in this conversation.