Preparing the Object for Use

One of the first decisions to make when creating the XMLHttpRequest object is whether your application will support IE 6.x. In IE 7, and in newer versions of the other browsers (Opera, Firefox, Safari, Netscape, and so on), the server request object is simply XMLHttpRequest, and the browsers all support similar behavior. However, IE 6.x still supports the older Microsoft ActiveX object. Since older Windows operating systems, such as the very popular Windows 2000, cannot support the newer IE 7, you have to decide whether you will provide support for people using Windows 2000 (or those using Windows XP who have not upgraded their browsers).

This is where you return to your logs and see how many people access your site using IE 6.x. If you have even five percent using IE 6.x, you're most likely going to want to support this older browser. Fortunately, the additional code doesn't take a lot of extra space.

The next issue when working with the ActiveX object is determining which object ID to set in the function call to create the object. Unfortunately, Microsoft was not consistent with the name of this object by operating system, and we have variations such as MSXML2.XMLHttp, MSXML2.XMLHttp.3.0, and MSXML2.XMLHttp.4.0. Most Ajax libraries focus on two of these, the older ID, Microsoft.XMLHttp, and the more common of the newer ones, MSXML2.XMLHttp.

Since most browsers that access the site will have access to the now-standard XMLHttpRequest object, it's most efficient ...

Get Adding Ajax now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.