使用div jQuery刷新文件

时间:2013-02-07 21:44:49

标签: jquery ajax templates refresh smarty

我有这个.tpl文件:

{include file="companies-list.tpl"}

我想使用div jQuery每隔5秒自动刷新一次{include file="companies-list.tpl"}。 有可能吗?

2 个答案:

答案 0 :(得分:1)

尝试这个

       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);

答案 1 :(得分:0)

您需要一个只显示所包含文件的页面。

setInterval( function() { $('#yourdiv').load("companies-list.php"); }, 5000 );

这不理想(需要错误检查和超时等功能),但它应该让你走在正确的轨道上。