Skip to content
Advertisement

Updating HTML Table Every 60 Seconds

I am trying to use an ajax call to update an HTML table every 60 seconds on a flask app. I am very new to flask and jquery, and followed this similar stackoverflow question: Python Flask Refresh table every 60 seconds

However my table isn’t displaying any data.

Currently my app.py file is setup as below:

And my nfl_template.html:

When I run the app, I get a page showing just the table headers but no data. I know that the SQL Query is correct and is returning data as I tested it separately, but using the ajax request I’m not getting any data to display.

If I run the SQL query inside the nfl route function and pass the data as an argument to the render_template the data displays, but it is not updating the table every 60 seconds.

Advertisement

Answer

If that is literally your entire template, then the problem is that you haven’t imported jQuery, so the “$” function doesn’t exist. You need to add:

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