jeudi 17 août 2017

javascript Uncaught SyntaxError: Unexpected number error

I make a website using google app-engine. I want to display table from google SQL database. So, I pass DB data to .html from .py using jinja2. but i have problem:

Uncaught SyntaxError: Unexpected number" (line 88 in .html)

line 88 is $.get(function()

all code is below:

<script type="text/javascript">
    var table;


    $(function(){
        $.get(function(){
            var jsonobj = JSON.parse();
            console.log(jsonobj);
            table = $('#userindex').dataTable({ 
                "sPaginationType": "bootstrap",
                "sDom": "t<'row'<'col-xs-6 col-left'i><'col-xs-6 col-right'p>>",
                "bStateSave": false
            });
            $.each(jsonobj, function(key,value){
                table.fnAddData(value[0],value[1],value[2],value[3], value[4],value[5],value[6],value[7]);
            });
        });
    });
</script>

jsondata can see F12:

[[1, "u1", 27, "M", "ad1", "01043343883", "A34B", 0], [2, "u2", 24, "M", "ad2", "01099248819", "A35B", 0], [3, "u3", 0, "M", "ad3", "01043724865", "A36B", 0], [4, "u4", 0, "M", "ad4", "01043734865", "A37B", 0], [5, "u5", 24, "M", "ad5", "15555215554", "A38B", 4]] 

and this is .py code

cursor.execute("""select no, u_name, age, gender, U_adress, phone, car_num, penalty from User;""")

data=cursor.fetchall() 
array_list=[]
for row in data:
  temp = (row[0],str(row[1]),row[2],str(row[3]),str(row[4]),row[5],str(row[6]),row[7])
  array_list.append(temp)   

jsondata=json.dumps(array_list)
db.commit()
db.close()

template_values = { 'jsondata':jsondata }

template = JINJA_ENVIRONMENT.get_template('User.html')
self.response.write(template.render(template_values))

enter image description here




Aucun commentaire:

Enregistrer un commentaire