OpenLayers.Request - OpenLayers

# OpenLayers. Request

The OpenLayers.Request namespace contains convenience methods for working with XMLHttpRequests. These methods work with a cross-browser W3C compliant OpenLayers.Request.XMLHttpRequest class.

Summary

OpenLayers. Request | The OpenLayers.Request namespace contains convenience methods for working with XMLHttpRequests.
Constants |
DEFAULT_CONFIG | {Object} Default configuration for all requests.
Functions |
issue | Create a new XMLHttpRequest object, open it, set any headers, bind a callback to done state, and send any data.
GET | Send an HTTP GET request.
POST | Send a POST request.
PUT | Send an HTTP PUT request.
DELETE | Send an HTTP DELETE request.
HEAD | Send an HTTP HEAD request.
OPTIONS | Send an HTTP OPTIONS request.

### Constants

### DEFAULT_CONFIG

{Object} Default configuration for all requests.

### Functions

### issue

> issue: function( | config | )

Create a new XMLHttpRequest object, open it, set any headers, bind a callback to done state, and send any data.

#### Parameters

config | {Object} Object containing properties for configuring the request. Allowed configuration properties are described below. This object is modified and should not be reused.

#### Allowed config properties

method | {String} One of GET, POST, PUT, DELETE, HEAD, or OPTIONS. Default is GET.
url | {String} URL for the request.
async | {Boolean} Open an asynchronous request. Default is true.
user | {String} User for relevant authentication scheme. Set to null to clear current user.
password | {String} Password for relevant authentication scheme. Set to null to clear current password.
proxy | {String} Optional proxy. Defaults to <OpenLayers.ProxyHost>.
params | {Object} Any key:value pairs to be appended to the url as a query string. Assumes url doesn’t already include a query string or hash. Parameter values that are arrays will be concatenated with a comma (note that this goes against form-encoding) as is done with <OpenLayers.Util.getParameterString>.
headers | {Object} Object with header:value pairs to be set on the request.
data | {Object} Any data to send with the request.
callback | {Function} Function to call when request is done. To determine if the request failed, check request.status (200 indicates success).
success | {Function} Optional function to call if request status is in the 200s. This will be called in addition to callback above and would typically only be used as an alternative.
failure | {Function} Optional function to call if request status is not in the 200s. This will be called in addition to callback above and would typically only be used as an alternative.
scope | {Object} If callback is a public method on some object, set the scope to that object.

#### Returns

{XMLHttpRequest} Request object. To abort the request before a response is received, call abort() on the request object.

### GET

> GET: function( | config | )

Send an HTTP GET request. Additional configuration properties are documented in the issue method, with the method property set to GET.

#### Parameters

config | {Object} Object with properties for configuring the request. See the issue method for documentation of allowed properties. This object is modified and should not be reused.

#### Returns

{XMLHttpRequest} Request object.

### POST

> POST: function( | config | )

Send a POST request. Additional configuration properties are documented in the issue method, with the method property set to POST and “Content-Type” header set to “application/xml”.

#### Parameters

config | {Object} Object with properties for configuring the request. See the issue method for documentation of allowed properties. The default “Content-Type” header will be set to “application-xml” if none is provided. This object is modified and should not be reused.

#### Returns

{XMLHttpRequest} Request object.

### PUT

> PUT: function( | config | )

Send an HTTP PUT request. Additional configuration properties are documented in the issue method, with the method property set to PUT and “Content-Type” header set to “application/xml”.

#### Parameters

config | {Object} Object with properties for configuring the request. See the issue method for documentation of allowed properties. The default “Content-Type” header will be set to “application-xml” if none is provided. This object is modified and should not be reused.

#### Returns

{XMLHttpRequest} Request object.

### DELETE

> DELETE: function( | config | )

Send an HTTP DELETE request. Additional configuration properties are documented in the issue method, with the method property set to DELETE.

#### Parameters

config | {Object} Object with properties for configuring the request. See the issue method for documentation of allowed properties. This object is modified and should not be reused.

#### Returns

{XMLHttpRequest} Request object.

### HEAD

> HEAD: function( | config | )

Send an HTTP HEAD request. Additional configuration properties are documented in the issue method, with the method property set to HEAD.

#### Parameters

config | {Object} Object with properties for configuring the request. See the issue method for documentation of allowed properties. This object is modified and should not be reused.

#### Returns

{XMLHttpRequest} Request object.

### OPTIONS

> OPTIONS: function( | config | )

Send an HTTP OPTIONS request. Additional configuration properties are documented in the issue method, with the method property set to OPTIONS.

#### Parameters

config | {Object} Object with properties for configuring the request. See the issue method for documentation of allowed properties. This object is modified and should not be reused.

#### Returns

{XMLHttpRequest} Request object.

> issue: function( | config | )

Create a new XMLHttpRequest object, open it, set any headers, bind a callback to done state, and send any data.

> GET: function( | config | )

Send an HTTP GET request.

> POST: function( | config | )

Send a POST request.

> PUT: function( | config | )

Send an HTTP PUT request.

> DELETE: function( | config | )

Send an HTTP DELETE request.

> HEAD: function( | config | )

Send an HTTP HEAD request.

> OPTIONS: function( | config | )

Send an HTTP OPTIONS request.
Standard-compliant (W3C) cross-browser implementation of the XMLHttpRequest object.
Close