[thelist] XMLHTTPRequest

Manektala, Udit Udit.Manektala at PIONEER.COM
Tue Dec 20 15:08:22 CST 2005


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
    Loop

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
lag.
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) {
		   alert(xmlhttp.responseText)
		  }
		 }

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: 

			dim ObjXMLHTTP
			Set ObjXMLHTTP =
Server.CreateObject("Microsoft.XMLHTTP")
			ObjXMLHTTP.open "GET", strURL, True
		      ObjXMLHTTP.send ""

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

This communication is for use by the intended recipient and contains
information that may be Privileged, confidential or copyrighted under
applicable law. If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited. Please notify the sender by
return e-mail and delete this e-mail from your system. Unless explicitly
and conspicuously designated as "E-Contract Intended", this e-mail does
not constitute a contract offer, a contract amendment, or an acceptance
of a contract offer. This e-mail does not constitute a consent to the
use of sender's contact information for direct marketing purposes or for
transfers of data to third parties.

Francais Deutsch Italiano  Espanol  Portugues  Japanese  Chinese  Korean

           http://www.DuPont.com/corp/email_disclaimer.html



More information about the thelist mailing list