Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > problem to display a "wait" message before fetching data using MS's XMLHTTP

Reply
Thread Tools

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

 
 
Alex Li
Guest
Posts: n/a
 
      02-12-2004
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.
 
Reply With Quote
 
 
 
 
Steve van Dongen
Guest
Posts: n/a
 
      02-12-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why rs.next() before fetching data??? parkarumesh@gmail.com Java 4 12-31-2007 06:05 PM
Fetching & Inserting Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET Bhavesh ASP .Net 5 07-18-2007 07:39 AM
Fetching & Inserting Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET Bhavesh ASP .Net 1 07-17-2007 09:05 AM
Inserting & Fetching Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET Bhavesh ASP .Net 0 07-16-2007 11:15 AM
Msxml*.XMLHTTP vs. Microsoft.XMLHTTP yawnmoth Javascript 11 11-09-2006 08:44 PM



Advertisments