Это мой HTML и код сервера:
<table id="example" class="display" style="width:100%">
<!-- 3 headers-->
<thead>
<tr>
<th>class</th>
<th>Email</th>
<th>Student_id</th>
<th>Username</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Class</th>
<th>Email</th>
<th>Student_id</th>
<th>Username</th>
</tr>
</tfoot>
</table>
<script>
function setupData() {
$(document).ready(function () {
$('#example').DataTable({
"processing": true,
"ajax": {
"type" :"GET",
"url":"/students",
"dataSrc": function(json){
var obj = (json);
console.log(obj);
return obj;
}
},
"columns": [
{ data:"user_class"},
{data: "user_email"},
{ data:"user_id"},
{ data:"user_username"}
]
});
});
}
$( window ).on( "load", setupData );
</script>
</body>
</html>
@app.route('/students', methods=['GET'])
def student_get():
cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
cursor.execute('SELECT * FROM students')
details = cursor.fetchall()
details = jsonify(details)
# details contains json array
return render_template('students.html', details=details)
Я хотел бы, чтобы данные отображались в таблице, но я продолжаю получать
нет данных
На основе моей консоли у меня есть 6 объектов. Извините, мои плохие навыки, я впервые использую Flask и jQuery.
Спасибо за вашу помощь.