Data table issue. First row is Loading.. and won't sorting ?

Data table issue. First row is Loading.. and won't sorting ?

UmitCamurcukUmitCamurcuk Posts: 1Questions: 1Answers: 0
edited April 2021 in DataTables

I have a endpoint in MVC project. that endpoint returns me json data . and i wanna show that data on datatable and sort in that datatable. ı wrote my code. data table shows me the data but first row is Loading... and sorting is not work. when i click the sorting name all data is dissapears. and max. row didn't work. how can i fix it ?

$(document).ready(function () {
        "ajax": {
            "type": "GET",
            "url": '/History/GetCallbackHistory',
            "data": { UserId: document.getElementById("callbackuserid").value },
            "dataSrc": "",
            "success": function (response) {
                $.each(response, function (i, dt) {
                    var body = "<tr>";
                    body += "<td>" + dt.Id + "</td>";
                    body += "<td>" + dt.DateCallback + "</td>";
                    body += "<td>" + dt.DateEnd + "</td>";
                    body += "<td>" + dt.Point + "</td>";
                    body += "<td>" + dt.TaskId + "</td>";
                    body += "<td>" + typecallback[dt.callbackId] + "</td>";
                    body += "<td>" + dt.Task_name + "</td>";
                    body += "<td>" + callbackStatus[dt.callbackStatus] + "</td>";
                    body += "</tr>";
   // fillTable(getData());

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


  • kthorngrenkthorngren Posts: 14,536Questions: 25Answers: 3,454

    The ajax docs state this:

    success - Must not be overridden as it is used internally in DataTables. To manipulate / transform the data returned by the server use ajax.dataSrc (above), or use ajax as a function (below).

    Datatables will automatically load the row data. You don't need to use success to load the data into the table. In fact Datatbles won't know about the data you load this way and is why you are seeing loading... as Datatables is unable to complete its loading process.

    See the ajax docs for more details. Also see the ajax examples.


Sign In or Register to comment.