jquery – .net core DataTables – sending null parameter via ajax to server
I have the following datatable
with server-side pagination:
<script>
$(document).ready(function () {
$("#example").dataTable({
pageLength: 10,
dom: '<"html5buttons"B>lTfgitp',
buttons: [
{ extend: 'excel', title: 'ExampleFile' }
],
"proccesing": true,
"serverSide": true,
ajax: {
type: "POST",
url: "url",
contentType: "application/json; charset=utf-8",
dataType: "jsonObject",
data: function (dtparams) {
return JSON.stringify(dtparams);
},
dataFilter: function (res) {
var parsed = JSON.parse(res);
return JSON.stringify(parsed.d);
},
error: function (x, y) {
console.log(x);
},
"filter": true,
columns: [
//columns
],
}
})
})
</script>
and my method on the server side:
public async Task<IActionResult> GetFilteredItems(string clientParameters)
{
//Code
}
My problem is that the client parameters sent to the server are null
but when I debug on the client side I can see the object like this:
I know there are some similar question about this, but I’ve tried some of those approaches like sending the object as Json.
Any ideas on this?
Read more here: Source link