1

While reading up on XMLHttpRequest found out that it is a member of the high level JS global window object. For instance:

if (window.XMLHttpRequest) { // Mozilla, Safari, IE7+ ...
    httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE 6 and older
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}

But I can't confirm this information anywhere else? I looked up here https://developer.mozilla.org/en-US/docs/Web/API/Window to see if I could locate the XMLHttpRequest object but there wasn't any mentioning of it. Am I missing something? Just want to make sure I am understanding the correct origin of XMLHttpRequest and how it relates to the global window object.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Asim Mahar
  • 1,320
  • 1
  • 10
  • 13

1 Answers1

1

See the WebIDL definition for the XMLHttpRequest interface:

[Constructor, Exposed=(Window,DedicatedWorker,SharedWorker)]
interface XMLHttpRequest : XMLHttpRequestEventTarget {
…
}

So that requires XMLHttpRequest to be exposed from Window and also from DedicatedWorker and SharedWorker (in UAs that actually implement those).

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197