Re: Call Wait Loop?
- From: "Tim" <tim j williams at gmail dot com>
- Date: Tue, 10 Jul 2007 13:28:21 -0700
I think the OP may be stuck with whatever has already been implemented
server-side.
As I understand it the first request fires off the process, second and
subsequent requests poll the server for process completion.
If not completed presumably the return message is "not done": if completed
then presumably it just grabs the result...
Tim
"Anthony Jones" <Ant@xxxxxxxxxxxxxxxx> wrote in message
news:%23yGLnSxwHHA.1168@xxxxxxxxxxxxxxxxxxxxxxx
"lucius" <lucius@xxxxxxxxxxxxxxxx> wrote in message
news:qp97935uk31hci5c8263dfdasoeildfend@xxxxxxxxxx
I don't have any code yet...
The first call does not expect any status or return. The second call
gets back a string (of XML) and it's up to the caller to determine
what is in it.
For sample purposes, I guess two functions "FirstCall()" and
"SecondCall()" would do me fine. I think the main thing I don't get is
how to structure my loops with setTimeout or whatever else I need to
do so the browser doesn't lock up completely. The code will eventually
run inside a much larger web page structure, so my stuff has to "play
nicely".
...ok, I just stated to write something but after 10 minutes I don't
have anything concrete.
Are you sure that this mechanism is necessary. The only advantage it has
over an asynchronous XML fetch is that it doesn't tie up a connection to
the
server. In the code below you need only on page that simply gets on with
whatever needs to be done and returns the results.
function getXMLAsync(sURL, fnResult)
{
var oXMLHttp
if (window.XMLHttpRequest)
oXMLHttp= new XMLHttpRequest()
else
oXMLHttp= new ActiveXObject("MSXML2.XMLHTTP.3.0")
oXMLHttp.open("GET", sURL, true)
oXMLHttp.onreadystatechange = fnRequestStateChange
oXMLHttp.send()
function fnRequestStateChange()
{
if (oXMLHttp.readyState == 4)
{
oXMLHttp.onreadystatechange = fnVoid
if (oXMLHttp.status == 200)
fnResult(oXMLHttp.responseXML)
else
fnResult(null)
}
}
}
function fnVoid() {}
var moXML = null;
function onResult(oXML)
{
moXML = oXML
if (moXML)
{
// Do stuff with XML
}
}
getXMLAsync("your url here", onResult)
The getXMLAsync returns imeadiately and control returns to the browser.
onResult fires when the request is complete.
--
Anthony Jones - MVP ASP/ASP.NET
Thanks.how
On Mon, 9 Jul 2007 23:17:01 -0700, "Tim Williams" <timjwilliams at
gmail dot com> wrote:
Make the first request then set a timeout for the second call. If no
results, set the timeout again.
Exact details will depend on specific information: for example
- does the first request return any status information ?
- what is returned from the second call if the info is not yet ready?
If you show the code you have so far, I'm sure you'll get suggestions on
to adapt it.
Tim
"lucius" <lucius@xxxxxxxxxxxxxxxx> wrote in message
news:7c4693hcjar64341c0fos3jghha8kpmauv@xxxxxxxxxx
I have a webservice that is async, so it takes 2 calls to get data: 1
to request it and 1 to see if there are results. The caller is
expected to wait 4 seconds for it to finish and then make call #2, if
no response then wait 4 seconds again.
Can anyone show a clever combo of setTimeout or equivalent so I can
get that functionality in JavaScript ib IE6 and IE7? I don't want to
lock up the browser while I'm waiting/looping...
Thanks.
.
- References:
- Call Wait Loop?
- From: lucius
- Re: Call Wait Loop?
- From: Tim Williams
- Re: Call Wait Loop?
- From: lucius
- Re: Call Wait Loop?
- From: Anthony Jones
- Call Wait Loop?
- Prev by Date: Re: Call Wait Loop?
- Next by Date: Re: obj.parentElement.parentElement.parentElement
- Previous by thread: Re: Call Wait Loop?
- Next by thread: Re: Call Wait Loop?
- Index(es):
Relevant Pages
|