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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Li

    #1

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

    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("tes t")" 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.d isplay = '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("P OST", cgiUrl, false);
    xmlhttp.Send(po stData);
    //antherDiv below is also pre-defined global DIV object.
    anotherDiv.inne rHTML = xmlhttp.respons eText;

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

    I would greatly appreciate any help!!!

    Alex.
  • Steve van Dongen

    #2
    Re: problem to display a "wait&quot ; message before fetching data using MS's XMLHTTP

    alex.li@pioneer .com (Alex Li) wrote:
    [color=blue]
    >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.displa y 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("tes t")" 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.d isplay = '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("P OST", cgiUrl, false);
    > xmlhttp.Send(po stData);
    > //antherDiv below is also pre-defined global DIV object.
    > anotherDiv.inne rHTML = xmlhttp.respons eText;
    >
    > waitDiv.style.d isplay = 'none'; // now hide "please wait ..."
    >}
    >
    >I would greatly appreciate any help!!![/color]

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

    Regards,
    Steve

    Comment

    Working...