Skip to content
Advertisement

render_template does nothing after receiving ajax content (flask, python, javascript)

I am passing data with ajax to my python function when a condition is met:

JavaScript

I know that the information is correctly received, since I can see it in the terminal through print:

JavaScript

But python does nothing after the print() function. Render or redirect both don’t work, the browser stays just as it is even though the information was passed:

JavaScript

Advertisement

Answer

You are not using ajax properly. You want to receive back a json response, not a complete web page.

Try:

JavaScript

Then:

JavaScript

This functionality really does nothing, as you already have errors in the calling template. If you are trying to go to finished, you would do that in the ajax success callback:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement