I have a problem in my code. I can't change the year values in my Datatable
This code gets the actual year:
var yearDate = new Date();
var year = yearDate.getFullYear();
My datatable method:
$(document).ready(function() {
januaryTable = $('#january').DataTable({
"processing": true,
"serverSide": true,
"order": [],
"ajax": {
"url": "<?php echo site_url('gastos/ajax_list/')?>" + year+'-01-01' +'/'+ year+'-01-31',
"type": "POST",
},
"columnDefs": [
{
"targets": [ -1 ],
"orderable": false,
},
],
});
}
This code reloads my datatable
function reload_january_table()
{
januaryTable.ajax.reload(null,false);
}
I change the var year with a select method and it calls the function reload_january_table(), but for example, when I select the value 2016, the table doesn't get values from 2016, it keeps the 2017 values.
Can someone help me ? And sorry for my english if it isn't good.