PDA

View Full Version : Ajax Tabs and trapping timeout



yabot
04-07-2009, 11:24 AM
1) Script Title: Ajax Tabs

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

3) Describe problem: Is it possible to trap a timeout if a page does not load when the tab is clicked? And in that way tell the user that "we are experiencing problems right now..."

ddadmin
04-07-2009, 09:06 PM
By timeout, do you mean the page actually failing to load, or just not load within a certain timeframe? For the former, it's easier to handle. Inside the .js file, try adding the code in red to the existing block below:


ddajaxtabs.loadpage=function(page_request, pageurl, tabinstance){
var divId=tabinstance.contentdivid
document.getElementById(divId).innerHTML=ddajaxtabssettings.loadstatustext //Display "fetching page message"
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
document.getElementById(divId).innerHTML=page_request.responseText
ddajaxtabs.ajaxpageloadaction(pageurl, tabinstance)
}
else
document.getElementById(divId).innerHTML='<b style="color:red">Error fetching content. Please try again later.</b>'
}

yabot
04-15-2009, 10:46 PM
In this way the text show up immediately and if the page load fast just flashes but not really a swell solution...

Would like to have something that kicks in when/if a page is not loaded.