Server Side Processing not working throwing "Cannot read property 'length' of undefined"
Server Side Processing not working throwing "Cannot read property 'length' of undefined"
Hi Alan,
I am trying to populate data table using server side processing but its not working..Trying this for several hours but no luck.I don't know whether i'm missing something.Please help.Here is my datatable debugger url: http://debug.datatables.net/eguwer
HTML table
<table class="table table-striped table-bordered table-condensed" id="reportTable">
<thead>
<tr>
<th>Sl.No.</th>
<th>Document Name</th>
<th>Document Type</th>
<th>Authors</th>
<th>Upload</th>
<th>Last Modified</th>
<th>Expiry</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Response JSON
{"iTotalRecords":15,"aaData":[{"expiryDate":"28/03/2015","docName":"7800_standards.pdf","uploadDate":"31/03/2015_10:58:22:284","docType":"PDF Upload","author":"Prince Radhakrishnan","lastModified":"01/04/2015_12:48:49:877","slNo":"1"},{"expiryDate":"24/04/2015","docName":"Fractal_Tiger.jpg","uploadDate":"01/04/2015_12:48:49:877","docType":"Docx Upload","author":"Prince Radhakrishnan","lastModified":"01/04/2015_12:48:49:877","slNo":"2"}],"iTotalDisplayRecords":5,"sEcho":1}
Datatable initialisation
var table = $('#reportTable').dataTable({
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"bPaginate": true,
"bSort": true,
"iDisplayLength": 10,
"bInfo": true,
"sAjaxSource": "generateReportAJAX",
"sServerMethod": "POST",
"aoColumns": [
{"mData": "slNo"},
{"mData": "docName"},
{"mData": "docType"},
{"mData": "author"},
{"mData": "uploadDate"},
{"mData": "lastModified"},
{"mData": "expiryDate"}
]
});
But now, I'm getting Cannot read property 'length' of undefined error in browser.Any help would be appreciated.
Regards,
Prince
This question has an accepted answers - jump to answer
Answers
I am having similar issue but with latest release,
http://www.datatables.net/forums/discussion/27369/server-side-processing-bind-to-json-array-of-objects
it appears that datatable does not see your json but tries to measure array length anyway but array is null (from datatable perspective) so you get that exception in console. I am guessing you need to work on your json format. Well, I was gonna rollback to legacy but looks like will have the same problem.
You are right about the json format.I'm using java for the development Chrome console show the json response as: http://s21.postimg.org/c3wel8h0n/jsonresult.jpg.
It list as a parsing error in firefox.So i will work on it.btw which version of datatable are you using.?
1.10.6