I have this python app using flask having this core routes:
@app.route('/test_limit', defaults={'page':1}) @app.route('/test_limit/page/<int:page>') def test_results_limit(page): perpage=10 startat=page*perpage results = [] cursor = db.cursor() cursor.execute('SELECT * from pi_fb_limit limit %s, %s;', (startat,perpage)) table = list(cursor.fetchall()) return render_template('results_limits.html', table=table) @app.route('/infringement/FB/<int:id>') def infringement(id): cursor = db.cursor() cursor.execute('UPDATE p_test_search SET infringement = ''TRUE'' WHERE ID = %s', (id)) db.commit() return render_template('results_limits.html') In my HTML file "result_limits.html" I have this HTML code iterating MySQL resoult:
</table> <tbody> {% for tab in table %} <tr class="zoomin"> <th> {{tab[0]}} </th> <td> {{tab[9]}} </td> <td><button type="button" onclick="location.href='/infringement/FB/'+{{tab[0]}};return false;" class="btn btn-danger">Infringement</button></td> </tr> {% endfor %} </tbody> </table> All is working fine but my problem is that when the button above dinamically call the route @app.route('/infringement/FB/'), browser is redirected to result_limits.html. Instead I'd like to avoid any redirection and remain on the same page each row button is creating post (to update records).
Any suggestion? Thank you Regs SL