1

I'm using server-side processing in jQuery DataTables, but the rows aren't getting added to the table. They are present in the AJAX success, and the rows are also in the data parameter, but they aren't getting added to the 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

6
  • have u define the header in jquery datatable? Commented Aug 4, 2017 at 4:53
  • where is your datatable code? Commented Aug 4, 2017 at 4:58
  • 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. Commented Aug 4, 2017 at 4:58
  • just add this code --> async: false, in ajax.... Commented Aug 4, 2017 at 5:06
  • @SmartKiller still the same Commented Aug 4, 2017 at 5:09

1 Answer 1

2

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;
         }
    },     
Sign up to request clarification or add additional context in comments.

Comments

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.