I am getting this error in the console which is not letting me perform my task of fetching the values into the datatable. I will post my code below:
$(document).ready(function() {
var product_id = '<?php echo $product->product_id; ?>';
var table = $('table.container-fluid').dataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "agent/order/getProduct",
"data": { "pid": product_id }
},
});
$('#selectProduct').click(function() {
var id = $("#selectproduct").val();
var product = ('agent/order/getProduct?product_id=' + id);
table.ajax.url(product).load();
table.reload();
});
Below please find the controller code:
public function getProduct () {
$prod_id = $this->input->post('pid');
$this->load->model('order_m');
$prod = $this->order_m->getProductById($prod_id);
echo json_encode($prod);
}
In chrome when I check the issue, it points out to this: table.ajax.url(product).load();
Can anybody please help me with this issue?
In DataTables 1.10 naming convention has changed, see API for more information.
You need to initialize your table as $("#logTable").dataTable() with lower case d to get access to previous version API or with $("#logTable").DataTable() with upper case D to get access to newer API.
Initialize your table using DataTable() not dataTable() as shown below:
var table = $('table.container-fluid').DataTable({
// ... skipped ...
});
Alternatively, if you need to have access to older API and initialize with dataTable(), you can call newer API methods as shown below:
var table = $('table.container-fluid').dataTable({
// ... skipped ...
});
table.api().ajax.url(newURL).load();