I try to implement jquery datatable ajax-source usage in Django however have some problems. The ajax call is working great and get the response however after that aData is undefined
error is raised in javascript.
What would be the problem ?
These are what I have so far.
views.py
def model_history(request):
o = Model.objects.get(id=request.GET["pk"])
items_list = list(o.lastupdate_set.all().values())
return HttpResponse(simplejson.dumps(items_list),'application/json')
js
function viewModelHistory(pk){
url1 = "/model/history/?pk="+pk;
$('#history').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": url1,
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
}
listmodel.html
<table id="history">
<thead>
<tr>
<th>col1</th>
<th>col2</th>
<th>col3</th>
<th>col4</th>
<th>col5</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
fnCallback
do and what parameters does it expect? – ilvar Apr 30 '12 at 4:31