Reputation: 21
I have a server side data-table.
When I make an ajax
call, it does not send the given value in the text-box, it sends empty.
When I pass static data it's working fine.
This is fine:
var table = $("#tblUsers").DataTable({
"language":
{
"processing":
"<div class='overlay custom-loader-background'><i class='fa fa-cog fa-spin custom-loader-color'></i></div>"
},
"processing": true,
"serverSide": true,
"ajax":
{
"url": "/Client/GetData",
"type": "POST",
"dataType": "JSON",
'data': ({ ZoneID: zoneIDs })
},
"columnDefs": [
{
"targets": [0],
"width": "5%",
"hidden": true,
}
],
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
//console.log(nRow);
$(nRow).find("td:eq(0)").attr("hidden", true);
return nRow;
},
"columns": [
{
"data": "ClientDetailsID"
}]
});
But when I pass zoneid
from textbox value instead of static data it sends empty.
"data": { ZoneID: $("#txtSOmething").val() }
Upvotes: 1
Views: 891
Reputation: 3322
Change your data
to
data: function(d){
d.myValue = $("#txtSOmething").val();
}
The on the server look for myValue in the Request
. For example, asp mvc: Request.Form.Get("myValue")
Upvotes: 2