Name

XMLHttpRequest.open( ): initialize HTTP request parameters

Synopsis

void open(Stringmethod,
          String url,
          boolean async,
          String username, String password)

Arguments

method

The HTTP method to be used for the request. Reliably implemented values include GET, POST, and HEAD. Implementations may also support methods as well.

url

The URL that is the subject of the request. Most browsers impose a same-origin security policy (see The Same-Origin Policy) and require that this URL have the same hostname and port as the document that contains the script. Relative URLs are resolved in the normal way, using the URL of the document that contains the script.

async

Whether the request should be performed asynchronously or not. If this argument is false, the request is synchronous, and a subsequent call to send( ) will block until the response is fully received. If this argument is true or is omitted, the request is asynchronous, and an onreadystatechange event handler is typically required.

username, password

These optional arguments specify authorization credentials for use with URLs that require authorization. If specified, they override any credentials specified in the URL itself.

Description

This method initializes request parameters for later use by the send( ) method. It sets readyState to 1; deletes any previously specified request headers and previously received response headers; and sets the responseText, responseXML, status, and statusText properties to their default values. It is safe ...

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.