HOME  |  AJAX  |  SOLUTIONS  |  TECHNOLOGIES  |  E-COMMERCE  |  ABOUT US
The Basics
Unfortunatly, IE handles XMLHttpRequests differently than Mozilla/FireFox and Safari.  Thus, you need to provide two different scripts for your AJAX to work on the different browser types. 

Internet Explorer uses an ActiveX object to create its XMLHttpRequst object.  To create the object use:
var myRequest = new ActiveXObject("Microsoft.XMLHTTP");

In Mozilla/FireFox and Safari, you can just use a native object like:

var myRequest = new XMLHttpRequest();

The apple developers network suggests checking which connection object to use with the following code:

var req;
 
function loadXMLDoc(url)
{
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}
Here is yet another way to get the XMLHttpRequest Object:
try
{
obj = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
obj = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e1)
{
obj = new XMLHttpRequest()
// Firefox
}
}