XmlHttp (Ajax) Show Waiting Message

G

Grant Merwitz

Hi

I have a form that submits to a web service.
As this takes time, i would like to show the user a loading message while
its loading.
I am using XmlHttp to do the request
How can i show this waiting message.
No matter what i do, it waits till everythings loaded before doing anything.

Currently:

<SCRIPT language="javascription">

function ButtonClick()
{
ShowLoadingMessage();
SubmitXmlHttpRequest();
}

function ShowLoadingMessage()
{
document.getElementById('statusmessage').innerHTML = 'Loading ...';
}

var xhttp;

function SubmitXmlHttpRequest()
{
xhttp = new ActiveXObject("Msxml2.XMLHTTP");
xhttp.onreadystatechange = GetXmlHttpResult;
xhttp.open("GET", http://mydomain.com/WebPageThatDoesProcessing,
false);
xhttp.send();
}

function GetXmlHttpResult()
{
if ( xhttp.readyState == 4 )
document.getElementById('statusmessage').innerHTML = 'Submitted';
}

</SCRIPT>

TIA
 
B

Bruce Barker

for the browser to update the display it needs to run a windows look
(doevents). you go into a hard loop and prevent this. try:

function ButtonClick()
{
ShowLoadingMessage();
window.setTimeout("SubmitXmlHttpRequest();",1);
}



-- bruce (sqlwork.com)
 
G

Grant Merwitz

Thanks Bruce, i'll give that a try.

I had previously tried 'setTimeout',
but not 'window.setTimeout'
 

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

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,247
Latest member
crypto tax software1

Latest Threads

Top