Unable to make a service call to server side

Unable to make a service call to server side

Chaitanya MokkapatiChaitanya Mokkapati Posts: 2Questions: 1Answers: 0
edited February 2020 in Free community support

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

 <table id="grid" class="display" style="width:100%  !important;height:50%">
    </table>

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 not initializing. There is no error in console also.

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

This discussion has been closed.