html – how to display json data from flask get output to datatables using agax-ThrowExceptions

Exception or error:

This is my HTML and server code:

<table id="example" class="display" style="width:100%">
    <!-- 3 headers-->
function setupData() {
    $(document).ready(function () {
             "processing": true,
             "ajax": {
                 "type" :"GET",

                 "dataSrc": function(json){
                      var obj = (json);
                      return obj;

            "columns": [
                { data:"user_class"},
                {data: "user_email"},
    { data:"user_id"},
                { data:"user_username"}
$( window ).on( "load", setupData );


@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)

I would like to have data displayed in the table but I keep getting

no data available

Based on my console I have 6 objects. Excuse my poor skills, this is my first time using Flask and jQuery.

Thank you for your help.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *