"Cliff" <cl***@thesolutioncafe.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
I'm not that great with ASP but I've hacked together a simple server
side script that uses the Microsoft XML ServerXMLHTTP object. The
problem is that when other people use the script sometimes they get an
error that the object can not be created, due likely to the required
Microsoft XML libraries not being installed. I'd like to try creating
the XMLHTTP object in an if/else block so that if the object can not be
created then it tries another object creation approach... here is the
code I'm using to create the object:
var objSrvHTTP=Server.CreateObject("MSXML2.ServerXMLHT TP.4.0");
The above line often fails because the object doesn't exist so I would
like to trap the error and try to create the object like:
var objSrvHTTP=Server.CreateObject("MSXML2.ServerXMLHT TP");
Can someone provide me with the code snippet that will result in the
variable objSrvHTTP having a ServerXMLHTTP object inside that works?
Also, if there are other variations on that object name then please
include those objects as well...
FYI, I'm only using open, setRequestHeader, send and responseText
methods on the object.
Will this help? You can test is as-is.
<html>
<head>
<title>xmlhttpx.html</title>
<script type="text/javascript">
function getRequestObj() {
var ret = null;
var xml = [
"MSXML2.XMLHTTP.5.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP"];
if (window.ActiveXObject) {
for (var i=0; i<xml.length; i++) {
try {
ret = new ActiveXObject(xml[i]);
break;
} catch(e) {}
}
} else if(window.XMLHttpRequest) {
try {
ret = new XMLHttpRequest();
} catch(e) {}
}
return ret;
}
var sURL = "http://www.gabocorp.com/";
var oXML = getRequestObj();
oXML.open("GET",sURL,false);
oXML.send();
alert(oXML.responseText);
</script>
</head>
<body>
</body>
</html>
Also, check out this link:
Identify which components are installed on the server.
<URL:
http://www.planet-source-code.com/vb...odeId=8976&lng
WId=4>
It can be adapted to run on any user's PC as a VBS file instead of ASP.
Just remove "<%", "%>", "Server.", and "<BR>"
and change "Response.Write" to "WScript.Echo"
then save it as "Components.vbs" and run it via the command line
"cscript.exe //nologo Components.vbs Components.txt"