Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

i use jQuery Datatables to display some Data. It works perfect but in case the server provides no data, the plugin gives the following warning: "DataTables warning (table id = 'notes'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error."

Why does he not display the empty table message. What do i have to response from the server to display my message like "There are no entrys ..."

Thank you

I found the solution for my problem

The Server-Response have to be an empty object that looks like this:

{"data":[]}

U have to set the property-name (is my case "data") in the Datatables init-code like:

var oTable_Notes = $("#notes").dataTable({
    ...
    "sAjaxDataProp": "data",
    ...
});

Then, if "data" is empty he shows the "sEmptyTable" - message ...

share|improve this question
    
Provide your code – Pavlo Mar 6 '14 at 8:36
    
isn't it obvious that the data returned from server in JSON format is not matching the format needed by JQuery datatable – Satya Mar 6 '14 at 8:37
    
ok, but what he needs in my case? An empty JSON-Object? – d-bro82 Mar 6 '14 at 8:46

You should return JSON from server with appropriate format, for example:

{
    "sEcho": 1,
    "iTotalRecords": 0,
    "iTotalDisplayRecords": 0,
    "aaData":[

    ]
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.