AJAX Post will not allow render_template or return redirect(url_for ...) - SOLVED

by: glennf, 7 years ago

Last edited: 7 years ago

After I send :

$.ajax({
url: '/matrix_update/',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(html_table_data),
type: 'POST'

I cannot return render_template or return redirect(url_for ....) and no flashed messages are shown on the html template.
The code executes correctly, processing the JSON data received and updating the MYSQL database but will not allow me to send the flash regarding successful execution or render the template. I even tried going to a different template but that will not execute either.  
I watched the JSON tutorial again but did not uncover an answer.
Any guidance is appreciated.
Thank you.

this did the trick
added to ajax:
success: function(response) {

            window.location.href = "/matrix_update";

}

and changed Python render template to:
return json.dumps({'success': True}), 200, {'ContentType': 'application/json'}



You must be logged in to post. Please login or register an account.