The Ajax Object: XMLHttpRequest and IEâs ActiveX Objects
Microsoft was the first company to implement
XMLHttpRequest as an ActiveX object. Mozilla
followed with a direct implementation of
XMLHttpRequest, and other companies have
responded with their own browsers: Apple and Safari, Netscape and
Navigator, and Opera. Though the constructor for the objects differs
between the two formats, each shares the same functionality and methods.
Once the initial object is created and assigned a variable, the one
cross-browser issue is resolved. But taking care of this issue isnât as
simple as it first looks.
Object, Object, Who Has the Object?
13-1 demonstrates one way to create an
XMLHttpRequest object: using a conditional
statement and testing for its existence. If it doesnât exist, the
object is created as an
ActiveXObject; it passes in the
progID (program ID) of the ActiveX objectâin
However, a possible problem with this is that the object used in the
ActiveXObject method call may
differ from machine to machine. Among the various versions of the
object could be
You can try to resolve every version of the
XMLHttp object, but most Ajax libraries and
applications focus on just two: the older
Microsoft.XMLHttp, and the base version of
MSXML2.XMLHttp. In addition, since Microsoft throws errors if it attempts to create an ActiveX object that doesnât exist, developers use this to ...