So I've been trying to get this to work with Ajax and JQuery, but I can't seem to get it. I'm new to both of these. Sorry if this is trivial, I've been searching and working off previous answers for awhile now.
Info:
I have a Jinja tag in my page html that I would like to update once per second:
<pre id="#system_info_tag">{{ system_info_text }}</pre> The information is originally (and successfully) populated from my main python script in a larger function called get_system_info():
@app.route('/') def root(): return render_template('system_info.html', system_info_text=get_system_info()) I would like the element to automatically reload once per second though, so I am trying to do that with JS as follows (which I thought would re-run my python function, as re-loading the page updates it):
function() { setInterval(function() { $("#system_info_tag").load(location.href + " #system_info_tag"); }, 1000); }); which is loaded in my html file with:
<script src="static/js/update_refresh.js"></script> The page loads fine with the correct information, but the element doesn't auto-reload. Any help would be much appreciated.
console.log("updating system info")in your update function ... also i dont think you want to loadlocation.href + " #system_info_tag"that doesnt make any sense