0
votes

I am using server side in jQuery datatables but the rows are not adding to table.its coming in ajax success ,rows are also coming in data parameter but its not adding to table.

otable = $('#siteselectiontable').DataTable({
    "serverSide": true,
    "deferLoading": 0,
    "processing": true,
    "paging": true,
    "columns": [{
        "data":"RADIO"
    },
    {
    "data":"SITE_DATA"  
    }
    ],
    "ajax": {
        success: function(data) {
            if(typeof data['error']!="undefined"){
                bootbox.alert({
                    closeButton: false,
                    message: "<div class='alert alert-danger' role='alert'>" +
                        "<strong>Timeout Error: </strong>Please refine your search" +
                        "</div>"
                });
            }
        },
        beforeSend: function() {
            $("#siteselectionfooter").after(progress);
        },
        complete: function() {
            $(".loading-mask").remove();
        }
    },
    "searching": false,
    "ordering": false,
    "lengthChange": false,
    "pageLength": 5,
    "dom": '<"top"><"pull-right"f>t<"bottom center"p><"clear">',
    "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
        $('td:eq(0)', nRow).css({
            'text-align': 'center',
            'vertical-align': 'middle'
        });
    }
});  

and for the ajax call i am using the below:

table.ajax.url(url).load();  

how can i handle the server side error in a custom way ?
enter image description here

1
have u define the header in jquery datatable? - Se0ng11
where is your datatable code? - Govind Samrow
i have define the headers ,rows were also coming ,but sometimes error is also coming which i want to show it my way ,for that i define the "success" but after adding it rows weren't added to table. - Harish Gupta
just add this code --> async: false, in ajax.... - Sumit Pathak
@SmartKiller still the same - Harish Gupta

1 Answers

1
votes

i have resolved this with dataSrc in ajax options and adding the below line

$.fn.dataTable.ext.errMode = 'none';    



"ajax": {
        beforeSend: function() {
            $("#siteselectionfooter").after(progress);
        },
        complete: function() {
            $(".loading-mask").remove();
        },
        "dataSrc": function ( json ) {
            if(typeof json['error']!="undefined"){
                bootbox.alert({
                    closeButton: false,
                    message: "<div class='alert alert-danger' role='alert'>" +
                        "<strong>Timeout Error: </strong>Please refine your search" +
                        "</div>"
                });
            }
            return json.data;
         }
    },