Unable to make service call in Data tables server side processing

吃可爱长大的小学妹 提交于 2020-03-05 03:11:09

问题


 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!