Error when there is no data to display JSON/AJAX

Error when there is no data to display JSON/AJAX

kezman10kezman10 Posts: 12Questions: 3Answers: 0

Good morning, I am recently implementing Datatable with ajax and json, and it works correctly for me, but I am finding that when I load the data if the result is zero data, it throws me an error like the following:

**DataTables warning: table id=listadoDocument - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1**

Thanks for all

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Have you followed the guide at the tech note the error message links to? What is the response from the server? If there is zero data you must send an empty array back - e.g.:

    {
      "data": []
    }
    

    Allan

  • kezman10kezman10 Posts: 12Questions: 3Answers: 0

    its works, thanks for all

Sign In or Register to comment.