XMLHttpRequest
The native object of modern browsers
Msxml2.XMLHTTP
Also valid as MSXML2.XMLHTTP.3.0 according to the knowledge base of no 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 this article in one of the MSDN 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 presented, here translated, are:
-
Compatibility - We do our best to maintain compatibility throughout the versions of MSXML, however, early versions such as MSXML 3 and MSXML 4 were implemented in the "Wild West" of the emergence of XML and much has been learned and improved over that time.
In addition, MSXML 5 for Microsoft Office Appointments was created with a specific focus for Microsoft Office scenarios. Sometimes for design or implementation issues you have to change things that affect the behavior of MSXML between your different versions
By iterating a collection of MSXML objects you open your Application for the potential risk of "bumping into" one of these differences unexpectedly.
- Robuztez - We can not fix all the bugs found in each of the many versions of MSXML and therefore we created MSXML6 (latest sup>) and MSXML3 (the most widely developed ), which have received large investments.
- Testing costs - The more versions of MSXML your Application potentially depends on, the more versions you have to test it before you apply it to your clients. / li>
[1] Translator's Note: As of the article's date in 2006