A
Alex Li
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.
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.