Django jquery datatable: Uncaught TypeError: Cannot read property 'length' of undefined
Django jquery datatable: Uncaught TypeError: Cannot read property 'length' of undefined
brk
Posts: 3Questions: 3Answers: 0
I'm trying to load data to jquery datatable from server in django 1.8.1. At the end of the process I'm getting "Uncaught TypeError: Cannot read property 'length' of undefined" javascript error.
View;
datas = Datas.objects.all()
jsonData = serializers.serialize('json', datas)
return HttpResponse(jsonData, content_type='application/json')
In the "Network" of browser it is seen that it returns json array like this;
[{"fields": {"objectname": "O1"}, "model": "my_app.datas", "pk": 1}]
Html;
<table class="table table-striped table-bordered table-hover" id="id_dataTable" style="cursor: pointer;">
</table>
Js;
$('#id_dataTable').dataTable({
"sAjaxSource": '/getData/',
"aoColumns": [
{'mData': 'fields.objectname'}
],
"aoColumnDefs": [
{
"aTargets": [0],
"sTitle": "Object",
"sClass": "align-center"
}
],
"bProcessing": true,
"bServerSide": true,
"bPaginate": false
});
Can you help ? thank you
This discussion has been closed.