My web api works fine.But datatable shows "no data available in table".I have attached the script.

My web api works fine.But datatable shows "no data available in table".I have attached the script.

piyu12345piyu12345 Posts: 3Questions: 3Answers: 0

$(document).ready(function () {
$('#tblEmployee').DataTable(
{
ajax: {
"url": "http://localhost:57507/api/Employee/Get",
"dataSrc": ""
}
,
columns : [
{ data: 'Employee_Id' },
{ data: 'Project_Id' },
{ data: 'Grade_Id' },
{ data: 'Site_Id' },
{ data: 'Location_Id' },
{ data: 'StartDate' },
{ data: 'EndDate' },
{ data: 'BillRate' },
{ data: 'Role' },
]
}
);
});

Answers

  • allanallan Posts: 63,852Questions: 1Answers: 10,519 Site admin

    We would need to be able to see an example of what your API is returning. From the above it should be:

    [
      {
        "Employee_Id": 1,
        "Project_Id": 2,
        ...
      },
      ...
    ]
    

    Allan

This discussion has been closed.