Class Index | File Index

Classes


Class glow.net.XhrRequest


Defined in: core.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
glow.net.XhrRequest(method, url, opts)
Create an XHR request.
Field Summary
Field Attributes Field Name and Description
 
Boolean indicating whether the request has completed
 
The request object from the browser.
Method Summary
Method Attributes Method Name and Description
 
Aborts a request The load & error events will not fire.
Event Summary
Event Attributes Event Name and Description
 
abort(event)
Fired when the request is aborted If you cancel the default (eg, by returning false) the request will continue.
 
error(response)
Fired when the request is unsucessful This will be fired when request returns with an HTTP code which isn't 2xx or the request times out.
 
load(response)
Fired when the request is sucessful This will be fired when request returns with an HTTP code of 2xx.
Class Detail
glow.net.XhrRequest(method, url, opts)
Create an XHR request. Most common requests can be made using shortcuts methods in glow.net, such as glow.net.get.
			new glow.net.XhrRequest('DELETE', 'whatever.php', {
				timeout: 10
			}).on('load', function(response) {
				alert( response.text() );
			});
Parameters:
{string} method
The HTTP method to use for the request. Methods are case sensitive in some browsers.
{string} url
Url to make the request to. This can be a relative path. You cannot make requests for files on other domains (including sub-domains). For cross-domain requests, see glow.dom.getJsonp and glow.dom.crossDomainGet.
{Object} opts Optional
Options object
{Object} opts.headers Optional
A hash of headers to send along with the request. eg `{'Accept-Language': 'en-gb'}`
{boolean} opts.cacheBust Optional, Default: false
Prevent the browser returning a cached response. If true, a value is added to the query string to ensure a fresh version of the file is being fetched.
{number} opts.timeout Optional
Time to allow for the request in seconds. No timeout is set by default. Once the time is reached, the error event will fire with a '408' status code.
{boolean} opts.forceXml Optional, Default: false
Treat the response as XML. This will allow you to use {@link glow.net.XhrResponse#xml response.xml()} even if the response has a non-XML mime type.
{Object|string} opts.data Optional
Data to send. This can be either a JSON-style object or a urlEncoded string.
Field Detail
{boolean} complete
Boolean indicating whether the request has completed
			// request.complete with an asynchronous call
			var request = glow.net.get(
				"myFile.html").on('load', 
				function(response){
					alert(request.complete); // returns true
				})

{Object} nativeRequest
The request object from the browser. This may not have the same properties and methods across user agents. Also, this will be undefined if the request originated from getJsonp.
Method Detail
abort()
Aborts a request The load & error events will not fire.
			var request = glow.net.get('myFile.html').on('load', function(response) {
				//handle response
			}).on('abort', function() {
				alert('Something bad happened. The request was aborted.');
			});
			
			request.abort(); // alerts "Something bad happened.  The request was aborted"
Returns:
this
Event Detail
abort(event)
Fired when the request is aborted If you cancel the default (eg, by returning false) the request will continue.
Parameters:
{glow.events.Event} event
Event Object

error(response)
Fired when the request is unsucessful This will be fired when request returns with an HTTP code which isn't 2xx or the request times out.
Parameters:
{glow.net.XhrResponse} response

load(response)
Fired when the request is sucessful This will be fired when request returns with an HTTP code of 2xx.
Parameters:
{glow.net.XhrResponse} response

Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jun 14 2010 14:24:09 GMT+0100 (BST)