1

I am implementing datatable. I can see data is coming from database in xhr using developer tools but it is not showing in the table. Please tell me what is the problem with my code.

@section Body{
<div class="row">

    <div class="col-md-9">

        <div class="block">

            <div class="content">
                <table cellpadding="0" cellspacing="0" width="100%" class="table" id="myDbTable">
                    <thead>
                        <tr>
                          <th data-hide>ID</th>
                            <th data-hide >Name</th>
                            <th data-hide >E-mail</th>
                            <th data-hide>Phone</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>

    </div>

</div>

}
  @section Scripts{
<script>

    var DataColumnsCount = 4;

    //***Start Fatching Data for datatable *** start //





function fetchEmployeeTableList() {

    $('#myDbTable').DataTable({

        "columns": [
               {"data" : "Id"},
               { "data": "Name" },
               { "data": "Email" },
                { "data": "Phone" }


        ]

    }
      );


}
$.ajax({
    type: 'GET',
    url: "@Url.Action("GetEmployees","Employee")",
    dataType: 'json',
    data: "{}",
    dataSrc: 'DataSet',
success: fetchEmployeeTableList});




 </script>
}

Please help me in this regard.

3
  • You have now placed the AJAX-call outside the dataTable init, it looked better in your previous identical post -> stackoverflow.com/questions/44082963/… but for some reason you have decided to shuffle the JS in a different order... Commented May 23, 2017 at 8:33
  • After lot of research Both the ways are not working so i decided to ask another question. Commented May 23, 2017 at 8:53
  • Apparently your research did not include the dataTables docs. See datatables.net/examples/ajax/objects.html or datatables.net/manual/ajax Commented May 23, 2017 at 8:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.