The OpenLayers.Request namespace contains convenience methods for working with XMLHttpRequests. These methods work with a cross-browser W3C compliant OpenLayers.Request.XMLHttpRequest class.
OpenLayers. Request | The OpenLayers.Request namespace contains convenience methods for working with XMLHttpRequests. |
Constants | |
DEFAULT_CONFIG | {Object} Default configuration for all requests. |
Properties | |
events | {OpenLayers.Events} An events object that handles all events on the {OpenLayers.Request} object. |
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. |
{OpenLayers.Events} An events object that handles all events on the {OpenLayers.Request} object.
request | {OpenLayers.Request.XMLHttpRequest} The request object. |
config | {Object} The config object sent to the specific request method. |
requestUrl | {String} The request url. |
complete | Triggered when we have a response from the request, if a listener returns false, no further response processing will take place. |
success | Triggered when the HTTP response has a success code (200-299). |
failure | Triggered when the HTTP response does not have a success code. |
issue: function( config )
Create a new XMLHttpRequest object, open it, set any headers, bind a callback to done state, and send any data. It is recommended that you use one GET, POST, PUT, DELETE, OPTIONS, or HEAD. This method is only documented to provide detail on the configuration options available to all request methods.
config | {Object} Object containing properties for configuring the request. Allowed configuration properties are described below. This object is modified and should not be reused. |
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. Typically, this is only appropriate for GET requests where the query string will be appended to the url. 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 | {String | Document} Optional data to send with the request. Typically, this is only used with POST and PUT requests. Make sure to provide the appropriate “Content-Type” header for your data. For POST and PUT requests, the content type defaults to “application-xml”. If your data is a different content type, or if you are using a different HTTP method, set the “Content-Type” header to match your data type. |
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. |
{XMLHttpRequest} Request object. To abort the request before a response is received, call abort() on the request object.
GET: function( config )
Send an HTTP GET request. Additional configuration properties are documented in the issue method, with the method property set to GET.
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. |
{XMLHttpRequest} Request object.
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”.
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. |
{XMLHttpRequest} Request object.
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”.
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. |
{XMLHttpRequest} Request object.
DELETE: function( config )
Send an HTTP DELETE request. Additional configuration properties are documented in the issue method, with the method property set to DELETE.
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. |
{XMLHttpRequest} Request object.
HEAD: function( config )
Send an HTTP HEAD request. Additional configuration properties are documented in the issue method, with the method property set to HEAD.
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. |
{XMLHttpRequest} Request object.
OPTIONS: function( config )
Send an HTTP OPTIONS request. Additional configuration properties are documented in the issue method, with the method property set to OPTIONS.
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. |
{XMLHttpRequest} Request object.
Create a new XMLHttpRequest object, open it, set any headers, bind a callback to done state, and send any data.
issue: function( config )
Send an HTTP GET request.
GET: function( config )
Send a POST request.
POST: function( config )
Send an HTTP PUT request.
PUT: function( config )
Send an HTTP DELETE request.
DELETE: function( config )
Send an HTTP HEAD request.
HEAD: function( config )
Send an HTTP OPTIONS request.
OPTIONS: function( config )