How to handle when server side processign return empty result?

How to handle when server side processign return empty result?

udhaya2kmrvudhaya2kmrv Posts: 6Questions: 4Answers: 0
edited April 2015 in Free community support

it showing invalid json format. It doest display no data found message:(

$('#example').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": "http://localhost/cig/pms/get_pending/" } );

My responce
{"draw":6,"recordsTotal":4,"recordsFiltered":0,"data":[],"error":"failure"}

This question has an accepted answers - jump to answer

Answers

  • survalentsurvalent Posts: 7Questions: 3Answers: 1
    edited April 2015 Answer ✓

    $.fn.dataTable.ext.errMode = 'none';
    $('#YourTable').on('xhr.dt', dataTableAjaxReturn);

    function dataTableAjaxReturn(e, settings, json) {

                if (typeof json.error != 'undefined') {
     //handle or ignore your error
                }
                else
                {
                  //no error
                }
    
            }
    
  • udhaya2kmrvudhaya2kmrv Posts: 6Questions: 4Answers: 0
    edited April 2015

    Thanks @survalent
    I forget check server side
    If server provide empty result thats a problem

    if(count($data)>0)
    //your data[]
    endif;

This discussion has been closed.