Mozilla adopted XMLHttpRequest immediately after its first release with Internet Explorer 5.0.
However, in Mozilla-equipped browsers the XMLHttpRequest object is part of the browser’s
object model and doesn’t rely on external components. Put another way, a Mozilla browser
such as Firefox publishes its own XMLHttpRequest object into the scripting engine and never
uses the COM component, even when the COM component is installed on the client machine
and is part of the operating system. Figure 1-4 shows the different models in Internet Explorer
(up to version 6.0) and Mozilla browsers.
As a result, in Mozilla browsers XMLHttpRequest looks like a native JavaScript object and can
be instantiated through the classic new operator:
// The object name requires XML in capital letters
var proxy = new XMLHttpRequest();
When the browser is Internet Explorer, the XMLHttpRequest object is instantiated using the
ActiveXObject wrapper, as shown here:
var proxy = new ActiveXObject("Microsoft.XmlHttp");
Generally, AJAX-style frameworks check the current browser and then decide about the route
to take.
Needless to say, as implemented in Mozilla browsers the XMLHttpRequest functionality is
somewhat safer, at least in the sense it doesn’t require users to change their security settings
for the browser.