Getting the XMLHttpRequest Object from Yahoo Maps
The following code is used on Yahoo Maps to obtain the XMLHttpRequest object on a given web browser.
Code Listing 1. Getting the XMLHttpRequest Object from Yahoo Maps
createXhrObject:function(E)
{
var D,A;
try
{
A=new XMLHttpRequest();
D={conn:A,tId:E};
}
catch(C)
{
for(var B=0;B<this._msxml_progid.length;++B)
{
try
{
A=new ActiveXObject(this._msxml_progid[B]);
D={conn:A,tId:E};
break;
}
catch(C)
{
}
}
}
finally
{
return D;
}
}
_msxml_progid:["Microsoft.XMLHTTP","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"]
Analyzing the XMLHttpRequest Code used on Yahoo Maps
The following figure shows various sections of the function that creates the XMLHttpRequest object for a given web browser on the Yahoo Maps page.
Figure 1. Analysis of Creating XMLHttpRequest Object on Yahoo Maps

Get the XMLHttpRequest on newer browsers
This code tries first to get the XMLHttpRequest object that is available on all the newer browsers (Internet Explorer 7, FireFox, Safari, and Opera).
var D,A;
try
{
A=new XMLHttpRequest();
D={conn:A,tId:E};
}
Get the XMLHttpRequest on older Microsoft browsers
If the current browser is older versions of Internet Explorer, the following code gets executed. This code has a clever way of using an array (_msxml_progid) to store various names of the XMLHTTP object used on the older IE versions. In newer browsers you can instantiate XMLHttpRequest() object; however in the older IE browsers, you would need to instantiate an ActiveXObject and pass it an XMLHTTP string.
for(var B=0;B<this._msxml_progid.length;++B)
{
try
{
A=new ActiveXObject(this._msxml_progid[B]);
D={conn:A,tId:E};
break;
}
catch(C)
{
}
}
Array of XMLHTTP strings
Various XMLHTTP strings from MSXML are stored in array (outside the above function). This facilitates the creation of ActiveXObject that is appropriate for the version of IE.
_msxml_progid:["Microsoft.XMLHTTP","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"]
Getting the XMLHttpRequest Object from Yahoo Mail
Following is yet another way of getting the XMLHttpRequest object. This time, it’s on Yahoo Mail.
Code Listing 2. Getting the XMLHttpRequest Object from Yahoo Mail
_newHTTP: function(bt)
{
var ret = null, e;
try
{
ret = new XMLHttpRequest();
}
catch (e)
{
e = ret = null;
}
if (!ret)
try
{
ret = new ActiveXObject(activeX.xmlhttp);
}
catch (e)
{
ret = null;
}
return (bt) ? {err:e,msg:"xmlhttp:failure\n"} : ret;
}
xmlhttp:MSXML2.XMLHTTP.3.0
Analyzing the XMLHttpRequest Code used on Yahoo Mail
The following figure shows various sections of the function that creates the XMLHttpRequest object for a given web browser on the Yahoo Mail page.
Figure 2. Analysis of Creating XMLHttpRequest Object on Yahoo Mail

Get the XMLHttpRequest object on newer browsers
By using new XMLHttpRequest(), create a new variable on the newer versions of the popular browsers.
var ret = null, e;
try
{
ret = new XMLHttpRequest();
}
Get the XMLHttpRequest object on older Microsoft browsers
For the older IE browsers, use the ActiveXObject.
try
{
ret = new ActiveXObject(activeX.xmlhttp);
}
XMLHTTP variable
Here the XMLHTTP from MSXML is stored as a variable outside the function.
xmlhttp:MSXML2.XMLHTTP.3.0
Links for XMLHttpRequest
Following are some source code and article links regarding XMLHttpRequest.
Source for XMLHttpRequest Method on window class from ASP.NET AJAX Library
Methods in XMLHttpExecutor class from the Sys.Net Namespace from ASP.NET AJAX Library
Classes from the Sys.Net Namespace from ASP.NET AJAX Library
XMLHttpRequest and AJAX on Google Suggest
XMLHttpRequest and AJAX on maps.live.com
XMLHttpRequest and AJAX on Yahoo
XMLHttpRequest and AJAX on mapquest.com