I use the datatables.net component for working with tables.

$('#nocTable').DataTable( { ajax: { url: "/Jobs/GetIncomingNoc", type: "POST", processData: false, data: function ( json ) { return json.ID = 10; }, contentType: "application/json" }, columns: [ {achTransactions: "transactionId"}, {achTransactions: { _: "transactionDate.year" } } ] } ); 

At the same time in Request Payload shows:

 [object Object] 

I suspect the problem is

  data: function ( json ) { return json.ID = 10; } 

How to do right?

    1 answer 1

    Working option:

     $('#nocTable').DataTable({ ajax: { url: "/Jobs/GetIncomingNoc", type: "POST", contentType: "application/json", data: function () { return JSON.stringify({ID: 10}); }, dataSrc: "achTransactions", }, columns: [ { data: "transactionId" }, {achTransactions: { _: "transactionDate.year" } } ] }); 

    The point is to pass a function to data that creates a valid json string:

      data: function () { return JSON.stringify({}); },