PDA

View Full Version : Javascript/Ajax - Adding a Loader



Lemon
02-26-2010, 09:44 PM
Hey Guys,

How would you add a loader to
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
Like so when it is loading the content it has an image saying loading or something.

Thanks.

Lemon
02-27-2010, 08:35 AM
Can anyone at all help :(?

Lemon
02-28-2010, 10:18 AM
I really need help.. Like putting this in (but I don't know where to put it and make it work)

$('').innerHTML = "<center><img src=''images/loading.gif"></center>";

Lemon
03-08-2010, 04:25 AM
These forums are useless, Haven't even got a reply..

Nile
03-08-2010, 04:39 AM
Try replacing:


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
}

With:


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

Nile
03-09-2010, 12:40 PM
Well... I've replied - and no response?

Lemon
03-10-2010, 10:53 AM
Try replacing:


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
}

With:


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


That's exactly what I wanted!

Thank you so much!!!

Nile
03-15-2010, 12:05 PM
Glad to help you! Your welcome!

It seems your topic is solved... Please set the status to resolved.. To do this:
Go to your first post ->
Edit your first post ->
Click "Go Advanced" ->
Then in the drop down next to the title, select "RESOLVED"