why Empty message not showing when use of datatable as serverside ?

why Empty message not showing when use of datatable as serverside ?

MithilTatvasoftMithilTatvasoft Posts: 4Questions: 2Answers: 0

here is my code spinet:

table = $('#example').DataTable({
        "language": {
            "lengthMenu": "Display _MENU_ records per page",
            "zeroRecords": "Nothing found - sorry",
            "info": "Showing page _PAGE_ of _PAGES_",
            "infoEmpty": "No records available",
            "infoFiltered": "(filtered from _MAX_ total records)"
        },
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "DataTableServerSide.aspx/GetTableData",
        "fnServerData": function (sSource, aoData, fnCallback) {
            $.ajax({
                "dataType": 'json',
                "contentType": "application/json; charset=utf-8",
                "type": "GET",
                "url": sSource,
                "data": aoData,
                "success": function (msg) {
                        var json = jQuery.parseJSON(msg.d);
                        fnCallback(json);
                        $("#example").show();
                },
                error: function (xhr, textStatus, error) {
                    if (typeof console == "object") {
                        console.log(xhr.status + "," + xhr.responseText + "," + textStatus + "," + error);
                    }
                }
            });
        },
        responsive: {
            details: {
                type: 'column',
                target: '.glyphicon-info-sign',
                display: $.fn.dataTable.Responsive.display.modal({
                    header: function (row) {
                        var data = row.data();
                        return 'Details for ' + data[1];
                    }
                }),
                renderer: $.fn.dataTable.Responsive.renderer.tableAll({
                    tableClass: 'table'
                })
            }
        },
        columnDefs: [{
            className: 'control',
            orderable: false,
            targets: 0
        }],
        order: [1, 'asc']
    });

})

Action USER_NAME USER_LOCATION USER_DEPTNAME

Json rerun when no data found : {"d":"{\"sEcho\": 1,\"iTotalRecords\": 0,\"iTotalDisplayRecords\": 0,\"aaData\": [ ]}"}

Answers

  • allanallan Posts: 63,812Questions: 1Answers: 10,516 Site admin

    Not sure. Can you link to a page showing the issue please.

    Allan

  • MithilTatvasoftMithilTatvasoft Posts: 4Questions: 2Answers: 0
  • allanallan Posts: 63,812Questions: 1Answers: 10,516 Site admin

    When I load the page I get three rows shown. If I type 1 into the filtering box there is a Javascript error occuring:

    VM170:1 Uncaught SyntaxError: Unexpected end of JSON input

    That is being caused by the server returning:

    {"d":""}
    

    You are then trying to use $.parseJSON on d, hence the error.

    Allan

  • MithilTatvasoftMithilTatvasoft Posts: 4Questions: 2Answers: 0

    yes when there is no data after filtering then blank json returns even i try with : {"d":"{\"sEcho\": 1,\"iTotalRecords\": 0,\"iTotalDisplayRecords\": 0,\"aaData\": [ ]}"} json return as well but no data found message not occur and processing is going on.

This discussion has been closed.