Name

XMLHttpRequest: An HTTP request and response — Firefox 1.0, Internet Explorer 5.0, Safari 1.2, Opera 7.60: Object → XMLHttpRequest

Constructor

new XMLHttpRequest( )                     // All browsers except IE 5 and IE 6
new ActiveXObject("Msxml2.XMLHTTP")      // IE
new ActiveXObject("Microsoft.XMLHTTP")   // IE with older system libraries

Properties

readonly short readyState

The state of the HTTP request. The value of this property begins at 0 when an XMLHttpRequest is first created and increases to 4 when the complete HTTP response has been received. Each of the five states has an informal name associated with it, and the table below lists the states, their names, and their meanings:

State

Name

Description

0

Uninitialized

This is the initial state. The XMLHttpRequest object has just been created or has been reset with the abort( ) method.

1

Open

The open( ) method has been called, but send( ) has not. The request has not yet been sent.

2

Sent

The send( ) method has been called, and the HTTP request has been transmitted to the web server. No response has been received yet.

3

Receiving

All response headers have been received. The response body is being received but is not complete.

4

Loaded

The HTTP response has been fully received.

The value of readyState never decreases, unless abort( ) or open( ) are called on a request that is already in progress. Every time the value of this property increases, the onreadystatechange event handler is triggered.

readonly String responseText ...

Get JavaScript: The Definitive Guide, 5th Edition 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.