I am using jQuery datatable plugin for display data but getting this error: aoData.push is not a function when I am passing my custom variable to datatable.
Any idea about this error?
Here is my script code:
$(document).ready(function() {
table = $('#table').DataTable({
"processing": true, // Feature control the processing indicator.
"serverSide": true, // Feature control DataTables' server-side processing mode.
// Load data for the table's content from an Ajax source
"ajax": {
"url": "<?php echo site_url('admin/invite_instagrammers/GetInstagrammersData')?>",
"type": "POST"
},
// "fnServerParams": function (aoData) {
// aoData.push({name: "pid", value: '15'});
// },
"oLanguage": {
"sProcessing": "Loading records..."
},
// Set column definition initialisation properties.
"columnDefs": [{
"targets": [-1], // Last column
"orderable": false, // Set not orderable
}, ],
});
$('.search-inp').on( 'keyup click', function () { // For text boxes
var i = $(this).attr('data-column'); // Getting column index
var v = $(this).val(); // Getting search input value
table.columns(i).search(v).draw();
});
$('.search-inp').on( 'change', function () { // For select box
var i = $(this).attr('data-column');
var v = $(this).val();
table.columns(i).search(v).draw();
});
});
function reload_table() {
table.ajax.reload(null, false); // Reload datatable ajax
}
and I have added this code to my datatable:
"fnServerParams": function (aoData) {
aoData.push({name: "pid", value: '15'});
},