【问题标题】:jQuery and MSXMLjQuery 和 MSXML
【发布时间】:2009-04-28 23:47:07
【问题描述】:

MSXML6 应该具有最佳的安全性、性能、可靠性和 W3C 一致性 (Using the right version of MSXML in Internet Explorer)。

问题:

  1. 为什么 jQuery 不使用 MSXML6?
  2. jQuery 是否使用 MSXML3? (我认为答案是肯定的,请参阅下面的更新...)
  3. 我可以从IXMLDOMDocument 实例中获取MSXML 的版本吗?如果有,怎么做?

更新:

我根据 Deviant 的回答做了一些研究:

jQuery 创建IXMLHTTPRequest 对象,该对象最初是与MSXML 2.0 一起发布的,如下所示:

new ActiveXObject("Microsoft.XMLHTTP");

Microsoft.XMLHTTPProgID,即 only implemented in MSXML3 for legacy support,不推荐使用。如果我正确理解the reference,这将创建一个版本2.x IXMLHTTPRequest 对象,在这些版本是“kill-bitted” 之前。现在我很确定这个 ProgID 创建了一个 MSXML 3.0 IXMLHTTPRequest 对象。这可能会回答我的第二个问题。

以下示例代码展示了如何创建IXMLHTTPRequest 对象的两个推荐版本:

new ActiveXObject("MSXML2.XMLHTTP.3.0"); // MSXML 3.0 ProgID...
new ActiveXObject("MSXML2.XMLHTTP.6.0"); // MSXML 6.0 ProgID...

我在 MSXML3 和 MSXML6 中测试了 XSLT 的性能。对于一个相当大的 XML 文件,MSXML6 用不到 1/10 的时间来执行与 MSXML3 相同的转换!

引用:

  1. jQuery: The Write Less, Do More, JavaScript Library
  2. IXMLHTTPRequest
  3. MSXML API History
  4. GUID and ProgID Information
  5. Using the right version of MSXML in Internet Explorer
  6. MSXML 3.0 GUIDs and ProgIDs
  7. MSXML 6.0 GUIDs and ProgIDs
  8. Why Version-Independent GUIDs and ProgIDs Were Removed

【问题讨论】:

    标签: javascript jquery internet-explorer msxml


    【解决方案1】:

    jQuery 可以。来源:

    // Create the request object; Microsoft failed to properly
    // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
    // This function can be overriden by calling jQuery.ajaxSetup
    xhr:function(){
         return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    },
    

    但它显然不能在 Firefox/chrome/safari/opera 等中使用 MSXML。因此,如果您尝试在 html 中使用 MSXML,您的网站将只能在 IE 中运行。所以我不建议你这样做。

    jQuery 仅使用 MSXML 作为备份来解决 MS 实现 XmlHttpRequest 中的错误。

    我不会说 MSXML 最符合 XMLHttpRequest 标准。 MSXML 早在 XMLHttpRequest 出现之前就存在了,所以这是一个奇怪的比较。 http://www.w3.org/TR/XMLHttpRequest/

    jQuery 曾经支持 XML 和 XPath 选择器,但已被弃用。有jQuery和XML的插件http://plugins.jquery.com/search/node/xml+type:project_project

    JSON 通常比 XML 更受欢迎。 http://json.org

    【讨论】:

    • IXMLHTTPRequest 是 MSXML 的一部分
    • @knut 他改变了他的问题,所以我的答案是关闭
    • IXMLHTTPRequest 是 Microsoft XML Lib 中的一个接口,与我在答案中链接的 Web 浏览器 DOM 对象 XMLHttpRequest 无关。你的问题非常广泛和模糊。你想达到什么目的? XML/XSLT 与 jQuery/JSON 对比? jQuery/JSON 是显而易见的选择。
    猜你喜欢
    • 1970-01-01
    • 2010-11-15
    • 1970-01-01
    • 1970-01-01
    • 2011-03-25
    • 1970-01-01
    • 1970-01-01
    • 2013-12-19
    • 2013-12-27
    相关资源
    最近更新 更多