我目前正在开发一个需要嵌套ajax标签的项目。我从动态驱动器中得到了一个例子。 Dynamic Drive - Nesting Ajax Tabs
我让标签工作正常但我希望嵌套标签的内容(例如“Tab3内容”)从上面提供的链接到每5秒自动刷新以显示更新。我将不胜感激。
<ul id="countrytabs" class="shadetabs">
<li><a href="external1.htm" rel="countrycontainer" class="selected">Tab1</a></li>
<li><a href="external2.htm" rel="countrycontainer">Tab2</a></li>
<li><a href="externalnested.htm" rel="countrycontainer">Tab3</a></li>
</ul>
// Main Tab content is displayed here (External tabs are displayed here too)
<div id="countrydivcontainer"> </div>
**Here is "externalnested.htm"**
<ul id="provincetabs" class="shadetabs">
<li><a href="external1.htm" rel="provincedivcontainer">Tab 1</a></li>
<li><a href="external2.htm" rel="provincedivcontainer">Tab 2</a></li>
<li><a href="external3.htm" rel="provincedivcontainer">Tab 3</a></li>
</ul>
// External Tab content is displayed here
<div id="provincedivcontainer"></div>
<script type="text/javascript">
var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()
countries.onajaxpageload=function(pageurl){
if (pageurl.indexOf("externalnested.htm")!=-1){
provinces=new ddajaxtabs("provincetabs", "provincedivcontainer")
provinces.setpersist(true)
provinces.setselectedClassTarget("link") //"link" or "linkparent"
provinces.init()
}
if (pageurl.indexOf("externalnested.htm")!=-1){
var seconds = 5000; // time in milliseconds
var reload = function() {
$.ajax({
url: 'nested-tab-1.php',
cache: false,
success: function(data) {
$('#countrydivcontainer').html(data);
setTimeout(function() {
reload();
}, seconds);
}
});
};
reload();
}
}
</script>
答案 0 :(得分:0)
if (pageurl.indexOf("externalnested.htm")!=-1){
var seconds = 5000; // time in milliseconds
var reload = function() {
$.ajax({
url: 'nested-tab-1.php',
cache: false,
success: function(data) {
$('#countrydivcontainer').html(data);
}
});
};
var timer=setInterval("reload()", seconds);