Msxml3.XMLHTTP In which case is it used?

Asked

Viewed 163 times

2

I was reading the following topic: Ajax request with pure Javascript (no Apis)

There they show the following line of code:

var XMLHttpFactories = [
    function () {return new XMLHttpRequest()},
    function () {return new ActiveXObject("Msxml2.XMLHTTP")},
    function () {return new ActiveXObject("Msxml3.XMLHTTP")},
    function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];

I know that for Firefox, Opera 8.0+, Safari = XMLHttpRequest(); is the basics

To Internet Explorer = Msxml2.XMLHTTP

Which browsers use Microsoft.XMLHTTP and Msxml3.XMLHTTP?

Currently here at the company we use requisitions Ajax only with XMLHttpRequest(), Msxml2.XMLHTTP and Microsoft.XMLHTTP and I was wondering whether it would be necessary to add Msxml3.XMLHTTP

I’ve been doing some research and I haven’t found anything, if you can give me a light I’d be very grateful...

1 answer

1

Xmlhttprequest

The native object of modern browsers

Msxml2.XMLHTTP

Also valid as MSXML2.XMLHTTP.3.0 in accordance with the Knowledge base of MSDN this Activex object introduced with MSXML2, represents today a fallback for versions 5.x and 6.0 of Internet Explorer.

Msxml3.XMLHTTP

It should actually be Msxml2.XMLHTTP.3.0 because, second a comment on the MSDN discussion channel, there is no Progid valid which corresponds to Msxml3.XMLHTTP because the object was somehow "unified" and the specific versioning suffixed (Msxml2.XMLHTTP.3.0, Msxml2.XMLHTTP.6.0...)

Still according to the above MSDN article, this definition is the fallback for versions prior to Internet Explorer 7 as described on MSDN base Knowledge

Microsoft.XMLHTTP

Internet Explorer 5, as if someone still remembers it :p

Finally, an improved version of your code, also coming from the MSDN discussion channel with link above, if the native object does not exist:

if( !window.XMLHttpRequest )
{
  window.XMLHttpRequest = function()
  {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch( e ) { }
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch( e ) { }
    try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch( e ) { }
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch( e ) { }
    throw "Could not create XMLHTTP object.";
  }
}

That’s because according this article in one of MSDN’s bloogs, the approach in which you list all possible objects and then iterate through the collection and instance to the one with the largest Progid, is wrong. And the reasons given here translated are:

  • Compatibility - We do our best to maintain compatibility throughout MSXML versions, but early versions such as MSXML 3 and MSXML 4 have been implemented in the "Wild West" of the emergence of XML and much has been learned and improved over that time.

    Additionally, MSXML 5 for Microsoft Office Apications was created with a specific focus for Microsoft Office scenarios. Sometimes for design or implementation reasons it is necessary to change things that affect the behavior of MSXML between its different versions

    By iterating a collection of MSXML objects you open your Application to the potential risk of "bumping into" one of these differences unexpectedly.

  • Robuztez - We cannot fix all the bugs found in each of the many versions of MSXML and therefore we have created MSXML6 (latest[1]) and MSXML3 (the most widely developed[1]), which received large investments.

  • Costs of the Tests - The more versions of MSXML your Application potentially depends on means the more versions you should test it on before interfacing it with your clients.

[1] Translator’s Note: Until the date of the article in 2006

Browser other questions tagged

You are not signed in. Login or sign up in order to post.