JavaScript:我应该使用哪个,Microsoft.XMLHTTP或Msxml2.XMLHTTP?

时间:2020-12-13 01:46:34

There are two progid's. I've seen both used.

有两个progid的。我见过两个都用过。

Anyone have any insight as to when I should use one, versus the other?

任何人都有任何见解,我应该何时使用一个,而不是另一个?

4 个解决方案

#1


2  

Hai Cheeso,

Hai Cheeso,

Have a look at these
http://bytes.com/topic/javascript/answers/559991-msxml-xmlhttp-vs-microsoft-xmlhttp

看看这些http://bytes.com/topic/javascript/answers/559991-msxml-xmlhttp-vs-microsoft-xmlhttp

http://forums.asp.net/p/1000060/1622845.aspx

http://forums.asp.net/p/1000060/1622845.aspx

#2


5  

You should definitely not use Microsoft.XmlHttp.

你绝对不应该使用Microsoft.XmlHttp。

From the Microsoft XML Team blog: Using the right version of MSXML in Internet Explorer:

从Microsoft XML团队博客:在Internet Explorer中使用正确版本的MSXML:

MSXML2 vs. Microsoft namespace – I’ve also seen a lot of code that instantiates the "Microsoft.XMLHTTP" ActiveX object rather than the MSXML2.XMLHTTP.3.0 or MSXML2.XMLHTTP.6.0 if you’re using 6.0. The “Microsoft” namespace is actually older and is only implemented in MSXML3 for legacy support. It’s unfortunate we used the “better” name on the older version, but stick to the “msxml2” namespace when instantiating objects.

MSXML2与Microsoft命名空间 - 如果您使用的是6.0,我还会看到很多代码实例化“Microsoft.XMLHTTP”ActiveX对象而不是MSXML2.XMLHTTP.3.0或MSXML2.XMLHTTP.6.0。 “Microsoft”命名空间实际上较旧,仅在MSXML3中实现以获得旧版支持。不幸的是,我们在旧版本上使用了“更好”的名称,但在实例化对象时坚持使用“msxml2”命名空间。

#3


1  

Maybe not exactly the answer you want, but that, if you are developping an Ajax application, I'd say you shouldn't use either of those : instead, you should use a Javascript Framework that will deal with browser compatibility, and not re-fight that battle.

也许不完全是你想要的答案,但是,如果你正在开发一个Ajax应用程序,我会说你不应该使用其中任何一个:相反,你应该使用一个Javascript框架来处理浏览器的兼容性,而不是 - 那场战斗。

For instance (there are many more) :

例如(还有更多):

And, as a sidenote, they'll get you plenty of other useful stuff ;-)

并且,作为旁注,他们会给你很多其他有用的东西;-)

#4


-1  

This code takes care of both IE and firefox.

此代码负责IE和Firefox。

try {
  XMLHttpRequestObject = new ActiveXObject("MSXML2.XMLHTTP");
} catch (exception1) {
  try {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (exception2) {
    XMLHttpRequestObject = false;
  }
}

if (!XMLHttpRequestObject && window.XMLHttpRequest) {
  XMLHttpRequestObject = new XMLHttpRequest();
}

#1


2  

Hai Cheeso,

Hai Cheeso,

Have a look at these
http://bytes.com/topic/javascript/answers/559991-msxml-xmlhttp-vs-microsoft-xmlhttp

看看这些http://bytes.com/topic/javascript/answers/559991-msxml-xmlhttp-vs-microsoft-xmlhttp

http://forums.asp.net/p/1000060/1622845.aspx

http://forums.asp.net/p/1000060/1622845.aspx

#2


5  

You should definitely not use Microsoft.XmlHttp.

你绝对不应该使用Microsoft.XmlHttp。

From the Microsoft XML Team blog: Using the right version of MSXML in Internet Explorer:

从Microsoft XML团队博客:在Internet Explorer中使用正确版本的MSXML:

MSXML2 vs. Microsoft namespace – I’ve also seen a lot of code that instantiates the "Microsoft.XMLHTTP" ActiveX object rather than the MSXML2.XMLHTTP.3.0 or MSXML2.XMLHTTP.6.0 if you’re using 6.0. The “Microsoft” namespace is actually older and is only implemented in MSXML3 for legacy support. It’s unfortunate we used the “better” name on the older version, but stick to the “msxml2” namespace when instantiating objects.

MSXML2与Microsoft命名空间 - 如果您使用的是6.0,我还会看到很多代码实例化“Microsoft.XMLHTTP”ActiveX对象而不是MSXML2.XMLHTTP.3.0或MSXML2.XMLHTTP.6.0。 “Microsoft”命名空间实际上较旧,仅在MSXML3中实现以获得旧版支持。不幸的是,我们在旧版本上使用了“更好”的名称,但在实例化对象时坚持使用“msxml2”命名空间。

#3


1  

Maybe not exactly the answer you want, but that, if you are developping an Ajax application, I'd say you shouldn't use either of those : instead, you should use a Javascript Framework that will deal with browser compatibility, and not re-fight that battle.

也许不完全是你想要的答案,但是,如果你正在开发一个Ajax应用程序,我会说你不应该使用其中任何一个:相反,你应该使用一个Javascript框架来处理浏览器的兼容性,而不是 - 那场战斗。

For instance (there are many more) :

例如(还有更多):

And, as a sidenote, they'll get you plenty of other useful stuff ;-)

并且,作为旁注,他们会给你很多其他有用的东西;-)

#4


-1  

This code takes care of both IE and firefox.

此代码负责IE和Firefox。

try {
  XMLHttpRequestObject = new ActiveXObject("MSXML2.XMLHTTP");
} catch (exception1) {
  try {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (exception2) {
    XMLHttpRequestObject = false;
  }
}

if (!XMLHttpRequestObject && window.XMLHttpRequest) {
  XMLHttpRequestObject = new XMLHttpRequest();
}