I have a checkbox in my datatables table header that I'm trying to pass as a parameter for server side processing. It seems like this should be trivial, but I'm either overlooking something or I am missing something with how datatables works.
This is my input:
<input id="active-users-chk" type="checkbox" name="active-users-chk" checked="checked"> Active Users Only
This works outside of the datatables initialization:
$('#active-users-chk').on('change', function(){
console.log($('#active-users-chk').is(':checked') ? 1 : 0);
$('#mng-users-table').DataTable().ajax.reload();
});
but if I try to use it dynamically as an ajax.data parameter, it's always true:
"ajax": {
"url": baseUrl + 'admin/get_users',
"type": "POST",
"data": {
"active_only": $('#active-users-chk').is(':checked')
}
},
I've tried everything I can think of, but can't seem to get this to work within the datatables initialization.