使用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调用,并使用计时器设置间隔