Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLHTTP response problems

Status
Not open for further replies.

kylua

Technical User
Sep 30, 2002
199
GB
Hi

I've got an ASP script that sends an XMLHTTP POST request to a server and gets a response. It was working perfectly until I called a script that caused my script to time out, which obviously means my entire script went down.

So I've tried to set it up so it sends it asynchronous and then loops until it has come back or 30 seconds has passed, whichever is first.

Set objXML = Server.CreateObject("MSXML2.XMLHTTP")
Response.Write itaggapi & "?" & params & "<br>"
objXML.Open "POST", itaggapi & "?" & params,true 'false
Response.write itaggapi & "?" & params
x = Time
objXML.send
do until objXML.ReadyState = "4" or time > x + 0.0003
loop
Response.write objXML.ReadyState
'Response.write objXML.responseText
if objXML.ReadyState = "4" then
'process the results
else
'state that there was a failure
end if


Everytime I set it to true for asynchronous it fails, everytime I set it to false it works fine. And when it fails the readystate is 1, when it succeeds it is 4.

Has anyone any idea what I am doing wrong?

Many thanks
 
If you set to async false, you practically do not need that timer. If you set to async true, inside the waiting loop, put some dummy operations. Nothingness there may eat up cpu cycle. As an example, use a synthetic sleep (But it assumes access to %comspec% and ping, otherwise try some dummy arithmetic.)
[tt]
do until objXML.ReadyState = "4" or time > x + 0.0003
createobject("wscript.shell").run "%comspec% /c ping -n 1 127.0.0.1>nul",0,true
loop
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top