Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Msxml*.XMLHTTP vs. Microsoft.XMLHTTP

Reply
Thread Tools

Msxml*.XMLHTTP vs. Microsoft.XMLHTTP

 
 
VK
Guest
Posts: n/a
 
      11-08-2006

Joe D Williams wrote:
> The only 'problem' being that the window.XMLHttpRequest
> seems to work slightlly diferent in IE7 than others by not
> allowing local rurl.


IXMLHTTPRequand (Microsoft) does work just fine with local files -
where allowed by the security environment, of course; but for them the
status code is reported 0 and not 200. This way the regular "Web check"
if (req.status == 200)
fails. To make an ajaxoid able to work with Web requests and with local
files the check has to be:
if ( (req.status == 200) || (req.status == 0) )

 
Reply With Quote
 
 
 
 
Matt Kruse
Guest
Posts: n/a
 
      11-09-2006
Joe D Williams wrote:
> So from what I can see, this should cover reasonable possiblilities?
> // create XMLHttpRequest request
> function createXMLHttpRequest()
> ...


I use this, which seems a little more robust:

/**
* Returns an XMLHttpRequest object, either as a core object or an ActiveX
* implementation. If an object cannot be instantiated, it will return null;
* @returns {Object} An XMLHttpRequest object
*/
AjaxRequest.getXmlHttpRequest = function() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// Based on http://jibbering.com/2002/4/httprequest.html
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
return null;
}
}
@end @*/
}
else {
return null;
}
};


--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments