Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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
使用divjquery刷新文件_Jquery_Ajax_Templates_Refresh_Smarty - Fatal编程技术网

使用divjquery刷新文件

使用divjquery刷新文件,jquery,ajax,templates,refresh,smarty,Jquery,Ajax,Templates,Refresh,Smarty,我有一个.tpl文件: {include file="companies-list.tpl"} 我想使用divjquery每隔5秒自动刷新{include file=“companys list.tpl”}。 有可能吗?您需要一个页面,该页面将仅呈现包含的文件 setInterval( function() { $('#yourdiv').load("companies-list.php"); }, 5000 ); 这并不理想(需要错误检查和超时功能等),但它应该会让您走上正确的道路。试试这

我有一个
.tpl
文件:

{include file="companies-list.tpl"}
我想使用divjquery每隔5秒自动刷新
{include file=“companys list.tpl”}

有可能吗?

您需要一个页面,该页面将仅呈现包含的文件

setInterval( function() { $('#yourdiv').load("companies-list.php"); }, 5000 );
这并不理想(需要错误检查和超时功能等),但它应该会让您走上正确的道路。

试试这个

       var refreshId = setInterval(function() {
       jQuery("#divid").load(yourfilename,
        function(response, status, xhr) {           
                    if (status == "error") {
                    var msg = "Sorry but there was an error: ";
    jQuery("#youdiv").html(msg + xhr.status + " " + xhr.statusText);
                          }
                });
         },5000);

您需要使用jquery进行ajax调用,并使用计时器设置间隔