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:.

Methods

Method

Description

abort()

Aborts the request

getAllResponseHeaders()

Returns all headers of the HTTP response

getResponseHeader(header)

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

send(content)

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 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.