Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web2py中的Javascript轮询_Javascript_Jquery_Ajax_Web2py - Fatal编程技术网

Web2py中的Javascript轮询

Web2py中的Javascript轮询,javascript,jquery,ajax,web2py,Javascript,Jquery,Ajax,Web2py,我的主视图文件中有以下代码: <html> <head> <script src="/app/static/js/jquery.js" type="text/javascript"> <script type="text/javascript"> jQuery(document).ready(function() {

我的主视图文件中有以下代码:

    <html>
            <head>
           <script src="/app/static/js/jquery.js" type="text/javascript">
            <script type="text/javascript">
                jQuery(document).ready(function() {
                    window.setTimeout(function() {
                        var url = '{{=URL('monitor.load')}}';
                        jQuery('#monitor').load(url);
                    }, 10000);
                });
            </script>
            </head>

            <body>
                <div id="monitor"></div>
            </body>
        </html>
但是,它在10秒后只放一次数据,然后它不会像我希望的那样每10秒更新一次数据…
如果数据在控制器中更改,或在monitor.load文件中更改
没有发生任何事情…

如果希望代码多次出现,则应使用
setInterval()

示例:

setInterval("alert('hello!');", 500);

上述代码将执行代码
alert('hello!')如果希望代码多次出现,则应使用
setInterval()

示例:

setInterval("alert('hello!');", 500);
上述代码将执行代码
alert('hello!')从页面加载到关闭,每500毫秒一次