By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,297 Members | 1,383 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,297 IT Pros & Developers. It's quick & easy.

problem to display a "wait" message before fetching data using MS's XMLHTTP

P: n/a
Dear js/xmlhttp experts,

I spent hours but could not solve this problem and hope someone could
give me a clue: a onclick event will invoke a function to do a few
things:
1. make a hidden DIV "wait" message visible by changing its
style.display to "block"
2. download the data with XMLHTTP
3. make the hidden DIV message invisible by setting its display to
"none".

If I insert "alert("test")" between 1 and 2, everything works fine.
However, if I comment out "alert" statement, step 1 will happen after
step 2, which totally defeats the purpose of "wait" message. The
detailed (simplified) is below:

function downloadData {
// waitDiv below is a pre-defined global DIV object
waitDiv.style.display = 'block'; // display "please wait ..."
alert("test"); // without this, the above statement execution
seems to be delayed.

// cgiUrl and postData are global.
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
xmlhttp.Open("POST", cgiUrl, false);
xmlhttp.Send(postData);
//antherDiv below is also pre-defined global DIV object.
anotherDiv.innerHTML = xmlhttp.responseText;

waitDiv.style.display = 'none'; // now hide "please wait ..."
}

I would greatly appreciate any help!!!

Alex.
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
al*****@pioneer.com (Alex Li) wrote:
Dear js/xmlhttp experts,

I spent hours but could not solve this problem and hope someone could
give me a clue: a onclick event will invoke a function to do a few
things:
1. make a hidden DIV "wait" message visible by changing its
style.display to "block"
2. download the data with XMLHTTP
3. make the hidden DIV message invisible by setting its display to
"none".

If I insert "alert("test")" between 1 and 2, everything works fine.
However, if I comment out "alert" statement, step 1 will happen after
step 2, which totally defeats the purpose of "wait" message. The
detailed (simplified) is below:

function downloadData {
// waitDiv below is a pre-defined global DIV object
waitDiv.style.display = 'block'; // display "please wait ..."
alert("test"); // without this, the above statement execution
seems to be delayed.

// cgiUrl and postData are global.
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
xmlhttp.Open("POST", cgiUrl, false);
xmlhttp.Send(postData);
//antherDiv below is also pre-defined global DIV object.
anotherDiv.innerHTML = xmlhttp.responseText;

waitDiv.style.display = 'none'; // now hide "please wait ..."
}

I would greatly appreciate any help!!!


You have to send the request asyncronously. See
http://jibbering.com/2002/4/httprequest.html for an example.

Regards,
Steve
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.