empty json

empty json

Andreas S.Andreas S. Posts: 208Questions: 74Answers: 4

I have a problem, if they result of a server-side query is null, I get the following error:

SCRIPT5007: Unable to get property 'length' of undefined or null reference
datatables.min.js (108,405)

The json data is following:

{"draw":"1","recordsTotal":0,"recordsFiltered":0,"options":[],"files":[]}

I think I send not all data, that are required, but I did not know witch. I tried, to send in this json string 'data':[] , but this part
are always removed, during the json_encode().
With this code I build the empty array

    $data = [
      'data' => [],
      'draw' => intval( 0 ),
      'recordsTotal' => intval( 0 ),
      'recordsFiltered' => intval( 0 ),
      'options' => [],
      'files' => []
    ]; 
    echo json_encode( $data );

Have someone a idea, where my fault is?

Andreas

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    {"draw":"1","recordsTotal":0,"recordsFiltered":0,"options":[],"files":[]}

    There is no data array. I don't understand why that would be since your PHP appears to include an empty data array.

    Allan

This discussion has been closed.