Reputation: 1316
below is my code in which I send an ajax call to my web method and get data from server to populate my HTML table, as you can see I am using Jquery DataTables to accomplish the task, and it is working fine
$('#example').DataTable({
"ajax": {
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "POST",
"url": "index.aspx/Risky",
"dataSrc": function (json) {
return $.parseJSON(json.d);
}
},
"columns": [
{ "data": "Prctice_Group_Risk_No" },
{ "data": "Practice_Group" },
{ "data": "Risk_Category" },
]
});
my question is how can i pass a parameter with this ajax call? I have seen everywhere on net but all those examples are about where its server side processing but here i am am using client side processing , I am not using fnsServerData or fnServerParams , Can anyone help me know how to pass a parameter with my ajax call?
Upvotes: 1
Views: 4609
Reputation: 58860
Use ajax.data
option to add or modify data submitted to the server upon an Ajax request.
$('#example').DataTable({
"ajax": {
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "POST",
"url": "index.aspx/Risky",
"data": function (d) {
d.extra_search = $('#extra').val();
},
"dataSrc": function (json) {
return $.parseJSON(json.d);
}
},
"columns": [
{ "data": "Prctice_Group_Risk_No" },
{ "data": "Practice_Group" },
{ "data": "Risk_Category" },
]
});
Upvotes: 1