[thelist] XMLHTTPRequest

Ken Schaefer Ken at adOpenStatic.com
Wed Dec 21 04:43:56 CST 2005


Hi,

I can't find the original post in this thread, so I'll reply to Peter's post.

For server-side automation you should not be using XMLHTTP interfaces. That
uses WinInet under the covers, and is not designed for multi-user scenarios.
If you want to see the types of things that happen, check my blog:
http://www.adopenstatic.com/cs/blogs/ken/archive/2005/04/16/15.aspx

The ServerXMLHTTP object allows you to specify whether the call should be
processed synchronously, or asynchronously, thus avoiding the need to "wait"
in a processor intensive loop.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/
bb76ab1d-abdd-4da6-a476-7d3d7c0f1f0c.asp?frame=true

See my blog post for a link to the start page for the ServerXMLHTTP object

Cheers
Ken

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Peter Brunone
(EasyListBox.com)
Sent: Wednesday, 21 December 2005 8:26 AM
To: thelist at lists.evolt.org; thelist at lists.evolt.org
Subject: Re: [thelist] XMLHTTPRequest

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

http://www.w3schools.com/xml/tryit.asp?filename=try_xmlhttprequest_vb
http://www.4guysfromrolla.com/webtech/102401-1.shtml

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.

Cheers,

Peter

 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
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

-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 



More information about the thelist mailing list