empty json to datatable

empty json to datatable

peterdiaspeterdias Posts: 1Questions: 1Answers: 0
edited January 2016 in Free community support

hello,

my datatable works gr8 wen there is data in the mysql table passed to it by json.
but wen there are no rows in mysql table, thats where the problem comes.

i have set this:

"language": {
                "infoEmpty": " ",
                "emptyTable": " ",
                "zeroRecords":    " - "

and this messages come, but i noticed in browser console that it keeps giving TypeError c is not defined.

wen there are no rows, i am returning this json :

   "{\"sEcho\": \"3\",\"iTotalRecords\": 0,\"iTotalDisplayRecords\": 0,\"data\":[]}"

pls can anyone help ?

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    That doesn't look like JSON - but rather just a simple string. You need to return:

    {
        "sEcho": "3",
        "iTotalRecords": 0,
        "iTotalDisplayRecords": 0,
        "data": []
    }
    

    Worth noting also that you are using the legacy format rather than the 1.10 format for whatever reason.

    Allan

This discussion has been closed.