Display problem

L

Lupus

Hi,

I've written a function in javascript to obtain content using AJAX.
While AJAX is loading, I want to show a div which says "please wait
while loading. This is a part of the function:

z.style.display = "none";
y.style.display = "block";

ajax = new AjaxHandler;
nt = ajax.send("ztbl_prestationlist.asp","");

y.style.display = "none";
z.style.display = "block";

z is the container div for the ajax content, and y is a "please wait
while loading"-div.

The function is triggered with <body onload=""> but also in the page
later on... When I open the page, it works perfectly, but when I
trigger the function to load other content, the div "y" does not
show...

What am I doing wrong ?


kind regards,
Mathew
 
L

-Lost

Lupus said:
Hi,

I've written a function in javascript to obtain content using AJAX.
While AJAX is loading, I want to show a div which says "please wait
while loading. This is a part of the function:

z.style.display = "none";
y.style.display = "block";

ajax = new AjaxHandler;
nt = ajax.send("ztbl_prestationlist.asp","");

y.style.display = "none";
z.style.display = "block";

z is the container div for the ajax content, and y is a "please wait
while loading"-div.

The function is triggered with <body onload=""> but also in the page
later on... When I open the page, it works perfectly, but when I
trigger the function to load other content, the div "y" does not
show...

What am I doing wrong ?

Break it down to its smallest component.

During the onprogress event of your XMLHttpRequest object display the element via:

validElementReference.style.display = 'block';

When the onload event of your XMLHttpRequest objects fires, hide the element via:

validElementReference.style.display = 'none';

validElementReference either being a single element of an object collection or an object
as found by getElementById.

-Lost
 
M

marss

Lupus said:
ajax = new AjaxHandler;
nt = ajax.send("ztbl_prestationlist.asp","");

y.style.display = "none";
z.style.display = "block";

z is the container div for the ajax content, and y is a "please wait
while loading"-div.

Hi,
Put the script that hides "please wait while loading"-div in the
function that process the result of XmlHttpRequest. If it is placed
right after ajax.send("ztbl_prestationlist.asp",""); then the div
hides as soon as request will be sent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,301
Latest member
BuyPureganics

Latest Threads

Top