Class GSXHR
Implements a cross-browser wrapper around the XMLHttpRequest object.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
GSXHR(options)
Creates a new
GSXHR instance. |
| Method Attributes | Method Name and Description |
|---|---|
|
cancel()
Cancels an in-flight request
|
|
|
Returns the response, interpreted according to the
Content-Type response header |
|
|
send(url, data)
Sends an HTTP request
|
Class Detail
GSXHR(options)
Creates a new
GSXHR instance.
- Parameters:
- {Object} options Optional
- an object literal specifying options to set:
- {Function} options.onSuccess
- a callback function to be invoked upon receipt of a success
response from the server (status >= 200 and < 300). The first argument to the callback is
the server response interpreted based upon the
Content-Typeresponse header, the 2nd argument is the raw server response as aString. - {Function} options.onFailure
- callback function to be invoked upon receipt of a
non-success response from the server. The first argument to the callback is
the server response interpreted based upon the
Content-Typeresponse header, the 2nd argument is the raw server response as aString. - {boolean} options.autoCancel
- if multiple requests are sent through this instance any in-flight
request will be canceled prior to sending a new request. Defaults to
false. - {String} options.method
- the HTTP method to use. Defaults to
GET. - {boolean} options.urlEncodeData
- if request data is passed to the
GSXHR.send()method, and this option is set totrue, the data will be URL-encoded prior to being sent to the server. Defaults totrue. - {String} options.contentType
- the content type of the request data. Defaults to
application/x-www-form-urlencoded.
Method Detail
cancel()
Cancels an in-flight request
{mixed}
getResponse()
Returns the response, interpreted according to the
Content-Type response header
- Returns:
- {mixed} the interpreted response
send(url, data)
Sends an HTTP request
- Parameters:
- {String} url
- the request URL
- {mixed} data
- the request data, specified either as
key-value pairs passed as an object literal OR as a
String