trouble with parsing array of obj from remote server (json)
trouble with parsing array of obj from remote server (json)
rsilva
Posts: 5Questions: 3Answers: 0
Thank you guys in advance for any help you might be able to provide me here.
I am getting this error:
jquery.dataTables.min.js:39 Uncaught TypeError: Cannot read property 'length' of undefined
Here's my markup:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Activity</th>
<th>Start</th>
<th>End</th>
<th>Description</th>
</tr>
</thead>
</table>
Here's my API call:
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"url": "//API_URL-XXXXXXXX",
"dataType": "json"
},
"aoColumns": [
{ "mData": "_id" },
{ "mData": "activity" },
{ "mData": "start" },
{ "mData": "end" },
{ "mData": "description" }
]
} );
Here's the network response: (validated as good json!)
200 OK
[{"_id":"56edd040c085311a00dfdf77","activity":"testing new","start":"03-22-2016","end":"03-22-2016","description":"<p>testing description</p>"},{"_id":"56edd0413625401a00b23a7b","activity":"testing new","start":"03-22-2016","end":"03-22-2016","description":"<p>testing description</p>"},{"_id":"56edd0423625401a00b23a7d","activity":"testing new","start":"03-22-2016","end":"03-22-2016","description":"<p>testing description</p>"},{"_id":"56edd046c085311a00dfdf79","activity":"testing new","start":"03-22-2016","end":"03-22-2016","description":"<p>testing description</p>"}]
I am probably missing something trivial. Can anybody spot the problem? Thank you!
This discussion has been closed.
Answers
I figured it out.
I was missing:
Found it via: https://datatables.net/manual/ajax
I hope this can help someone.