当我运行我的网络应用程序时,出现此错误。它说在这里发现错误:
var rows = ({'CurrentLocation': 'Norwich'}, {'CurrentLocation': 'Sheringham'}, {'CurrentLocation': 'Cambridge'})
这是我的代码:
def search():
cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
cursor.execute("SELECT CurrentLocation FROM driver WHERE OnJourney=0")
rows = cursor.fetchall() # data from database
return render_template("Search.html", rows=rows)
var rows = {{ rows }}
var row;
var locations = [];
for (row in rows) {
locations.push(row['CurrentLocation']);
}
var location;
for (location in locations) {
var origin = location;
}
有什么方法可以将该字典从 python 传递到 javascript 而不会出现此错误?感谢您的帮助
ABOUTYOU
相关分类