Python Forum
gettin flask to call script periodically - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: gettin flask to call script periodically (/thread-31890.html)



gettin flask to call script periodically - GrahamL - Jan-08-2021

As in the title I want a script to get called periodically
I have this script at the bottom of an html file
<script>
setInterval("ajaxd()",1000);
function ajaxd() {
$(document).ready(function(){alert("ready");})
}
</script>
but the alert is not called
Is the syntax correct?


RE: gettin flask to call script periodically - ndc85430 - Jan-08-2021

Why are you passing a string to setInterval instead of just passing the function (per the documentation)? That is

setInterval(ajaxd, 1000);

Functions have been first class in JavaScript for a long time and you make use of that when you call jQuery's ready method.

Also, did you remember to check the browser's console for errors?

Note also this has nothing to do with the server; this code is only executed in the browser.