Python Forum

Full Version: gettin flask to call script periodically
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.