I have a table populated with JSON from an AJAX call. Each row has a link to another Flask route. I am able to create the rows but the urls are not pointing to the correct id, they are empty. Why doesn't this work correctly?
var header = tab.createTHead();
var row = header.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = "<b>Col1</b>";
cell2.innerHTML = "<b>Col2</b>";
for (var i = 0; i<data.length; i++){
var row = tab.insertRow(i+1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var child = data[i]['_id'];
cell1.innerHTML = '<a href="/query/{{child}}" >' + child + '</a>';
cell2.innerHTML = (data[i]['similarity']).toFixed(3);
}
@app.route("/query/<hashcode>", methods=['GET',"POST"])
@app.route("/query/", methods=['GET',"POST"])
def query(hashcode=None):
if not hashcode == None:
print hashcode
sim = similarity(hashcode)
else:
print "None Received"
sim = []
return render_template('query2.html', hashcode = hashcode, sim = sim)
childin the curly braces in the linecell1.innerHTML = '<a href="/query/{{child}}" >' + child + '</a>';comes from?cell1.innerHTML = '<a href="/query/{{child}}" >' + child + '</a>';change tocell1.innerHTML = '<a href="/query/' + child + '" >' + child + '</a>';javascript won't parse that for you.