问题
Javascript
$('#grid').DataTable({
"processing": true,
"destroy": true,
"scrollY": true,
"scrollX": true,
"serverSide": true,
"paging": true,
"pageLength": 20,
"lengthChange": false,
"language": { search: '', searchPlaceholder: "Search..." },
"ajax":
{
"url":'api/Default/EmployeeDetails',
"contentType": "application/json",
"type": 'POST',
"dataType": "json",
"data": function (d) {
debugger;
return JSON.stringify(d);
},
"dataSrc": function (json) {
debugger;
//json.draw = json.draw;
//json.recordsTotal = json.recordsTotal;
//json.recordsFiltered = json.recordsFiltered;
//json.data = json.data;
var return_data = json;
//return return_data.data;
var dttt = $.parseJSON(return_data.data);
return dttt;
}
},
"columns": [
{
"data": "UserName",
"title": "Employee Name"
},
{
"data": "Password",
"title": "Passwords"
}, ]
HTML
Server side
[HttpPost("EmployeeDetails")]
public string EmployeeDetails([FromBody] PagingParams data)
{
SQLServerConnect connection = new SQLServerConnect();
string result = JsonConvert.SerializeObject(connection.EmployeeDetails("Employee", data));
return result;
}
I am unable to hit the service call. Ajax call is not initializing. So, unable to make service call to get the data for data tables. There is no error in console also. Help me out from this. Thanks in advance
来源:https://stackoverflow.com/questions/60145895/unable-to-make-service-call-in-data-tables-server-side-processing