Json without aaData

Json without aaData

lusabolusabo Posts: 18Questions: 0Answers: 0
edited March 2014 in DataTables 1.9
Is there a way to work with Datatables with sAjaxSource where the returned JSON has no aaData?

My table:

[code]



Id
Description
Link





[/code]

My javascript:

[code]
$('#exemplo').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "api/bookmark",
"sAjaxDataProp": "",
"aoColumns": [
{ "mData": "id" },
{ "mData": "description" },
{ "mData": "link" }
]
});
[/code]

The JSON returned by http://localhost:8080/bookmark-html5/api/bookmark:

[code]
[
{
"id": 10,
"description": "Demoiselle Portal",
"link": "www.frameworkdemoiselle.gov.br"
},
{
"id": 11,
"description": "Demoiselle SourceForge",
"link": "sf.net/projects/demoiselle"
}
]
[/code]

The following error is occurring in the browser:

[quote]
Uncaught TypeError: Cannot read property 'length' of undefined
[/quote]

Thanks!

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    > Is there a way to work with Datatables with sAjaxSource where the returned JSON has no aaData?

    Yes :-). Use sAjaxDataProp and set it to be an empty string.

    However!!! You have server-side processing enabled. To use server-side processing, you _must_ return an object (otherwise, how else will it be able to get multiple bits of information!). If you don't need server-side processing, just disable that option and sAjaxDataProp will do what you need. If you do need server-side processing, then your JSON is incomplete since it isn't returning the information needed.

    Allan
This discussion has been closed.