Appendix A. XMLHttpRequest Reference

This Appendix assembles all methods and properties that the XMLHttpRequest object exposes. Square brackets [] denote an array; parentheses () indicate a method.

To create an XMLHttpRequest object for Internet Explorer, you must use ActiveX:

XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");

With other browsers, the XMLHttpRequest object is a built-in type and can be instantiated directly, as in the following snippet:

XMLHTTP = new XMLHttpRequest();

Once the XMLHttpRequest object is instantiated, the following cross-browser methods and properties are supported:.





Aborts the request


Returns all headers of the HTTP response


Returns the value of the given HTTP response header

open(method, url, async, username, password)

Creates an HTTP request with the given method (GET or POST) to the given URL. The other parameters are optional: whether to use an asynchronous call (default) or not, and credentials for HTTP Authentication


Sends the HTTP request, optionally providing data to send with it (POST information)

setRequestHeader(name, value)

Adds a header with the given name and value to the HTTP request

Get Programming Atlas now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.