PDA

View Full Version : Dynamic Ajax content : Wait message



HyperCyber
12-13-2006, 10:27 PM
Dynamic Ajax content

http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

How can i add a waiting message while the page is loading ?
I wont just to display and hidding a hidden DIV

Thanks alot !

ddadmin
12-14-2006, 07:27 AM
Just find the lines:


page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}

and add beneath it something like:


page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
document.getElementById(containerid).innerHTML='<b>Loading Content. Please hold...</b>'

HyperCyber
12-14-2006, 11:05 AM
Thanks ! ;)

helenmarie123
09-27-2010, 10:06 AM
hello, I have added this code to my dynamic content script and I was wondering if there is a way to make it stay for say 1-2 seconds before the page loads? At the minute my pages are small so the loader flashes up for a millisecond, it would be nice for it to stay there so the user actually sees it.

Thank you

Helen

ddadmin
09-27-2010, 10:37 PM
Sure, try finding the following function inside the script:


function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}


and replace it with:


function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
if (typeof ajaxcontent_loadtimer!="undefined")
clearTimeout(ajaxcontent_loadtimer)
ajaxcontent_loadtimer=setTimeout(function(){document.getElementById(containerid).innerHTML=page_request.responseText}, 1000)
}
}

1000 in the above denotes 1 second (1000 milliseconds).

helenmarie123
09-28-2010, 12:10 PM
thats ace thank you very much :)