I get this error when I run my webapp. It says that the error is found here:
var rows = ({'CurrentLocation': 'Norwich'}, {'CurrentLocation': 'Sheringham'}, {'CurrentLocation': 'Cambridge'})
This is my code:
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;
}
Is there any way I can pass that dict from python to javascript without getting this error? Thanks for your help