[thelist] XMLHTTPRequest

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Tue Dec 20 15:25:59 CST 2005

A bit of googling "vbscript xmlhttp readystate" led me to this:


Hopefully that will help a bit...?

Also, is there any chance that your page is being cached (which would explain the usefulness of the refresh action)?  You might consider the code at http://learnasp.com/freebook/asp/cachenomore.aspx to see if it would make a difference.



 From: "Manektala, Udit" Udit.Manektala at PIONEER.COM

Okay, after a successful bit of advice from this list about using the
XMLHTTPRequest for a requirement ( thanks guys), I have run into another
problem.Im sending a Java Servlet link an XML and expecting another XML
in return, all using the XMLHTTPRequest object. The problem is strange,
that when I load the ASP page that contains this code, it goes into hang
and times out. I know the hang is coming from the 

Do while ObjXMLHTTP.readyState<>4
'Do Nothing

I know this because when I put in a Response.write in there, it gave me
a Buffer overflow error. Ok now, here's the funny part. When I hit F5
and Refresh, the whole page loads fine ... without a single second of a
So what I understand is that the readyState is not changing to 4 even
when the XML is ready, the first time 'round but it changes to 4 the
next time round ?..a little confused there. So I looked up those
XMLHTTPRequest Sample codes closely and realised that I don't have an
"onreadystatechange" function for the XMLHTTP object which could be the
cause of my problem. Now here's the second problem, I cdnt figure out
how to declare an eventhandler function right there because im thinking
ASP doesn't like a sub being declared inside a loop. So I tried
declaring it outside the loop which didn't work either, coz then I need
to pass the XML Document Object and the XMLHTTP object by Reference and
then do some jazz on it which really didn't work. So I hunted through
more code and found this example for Jscript where the function is
declared right where the onreadystatechange is specified. This I am
unable to replicate in VBScript ASP. 

xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {

So to cut a veery long story short, I wanna know why the loop goes in
hang and if the reason is what I think, how do I deal with this problem.

My ASP Code: 

ObjXMLHTTP.open "GET", strURL, True
ObjXMLHTTP.send ""

Do while ObjXMLHTTP.readyState<>4
'Do Nothing
if ObjXMLHTTP.readyState=4 then
xmlDoc.LoadXML objXMLHTTP.responseText
end if

More information about the thelist mailing list