Djangoでjquery datatable ajax-sourceの使用を実装しようとしましたが、いくつかの問題があります。ajax呼び出しはうまく機能し、応答を取得しますが、そのaData is undefined
エラーがjavascriptで発生した後.
問題は何ですか?
これらは私がこれまでに持っているものです。
ビュー.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>