I am using jquery datatable serverside ajax, secho is null
I am using jquery datatable serverside ajax, secho is null
tnomani
Posts: 1Questions: 1Answers: 0
{ sEcho = null, iTotalRecords = 132, iTotalDisplayRecords = 10, aaData = {System.Linq.OrderedEnumerable`2[LWOBPortal.Models.Product,System.String].Skip(0).Take(10)} }
theviewis
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.0/css/dataTables.dataTables.css" />
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://cdn.datatables.net/2.0.0/js/dataTables.js"></script>
<script>
$(document).ready(function () {
$('#tblProduct').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "/Product/GetData",
"type": "POST",
"iDisplayStart": 1,
"iDisplayLength": 10,
"success": function (d) {
console.log(d.data[0].id_documento);
},
},
"columns": [
{ "Data": "productName" },
{ "Data": "rate" },
{ "Data": "price" },
{ "Data": "lockPeriod" },
{ "Data": "productType" }
// Add other columns as needed
]
});
});
</script>
Answers
Looks like your server side processing script supports Datatables 1.9 based on the documented SSP parameters. Starting with Datatables 1.10 the parameters have changed as documented here. You will need to update your server side processing script to support these parameters or use Datatables supplied scripts - see this blog.
Kevin
Yes, that is one of the few breaking changes in DataTables 2. It removes a fair amount of the legacy stuff from 1.9 and earlier - specific the Hungarian notation for server-side processing and the legacy API.
Allan