Class Index | File Index

Classes


Namespace glow.net


Defined in: core.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Methods for getting data & resources from other locations.
Method Summary
Method Attributes Method Name and Description
<static>  
glow.net.crossDomainGet(url, opts)
Cross-domain get via window.name A request made via a form submission in a hidden iframe, with the result being communicated via the name attribute of the iframe's window.
<static>  
glow.net.crossDomainPost(url, data, opts)
Cross-domain post via window.name A request made via a form submission in a hidden iframe, with the result being communicated via the name attribute of the iframe's window.
<static>  
glow.net.del(url, opts)
Makes an HTTP DELETE request to a given url.
<static>  
glow.net.get(url, opts)
Makes an HTTP GET request to a given url.
<static>  
glow.net.getResources(url)
Load scripts, images & CSS.
<static>  
glow.net.jsonp(url, opts)
Fetch JSON via JSONP.
<static>  
glow.net.post(url, data, opts)
Makes an HTTP POST request to a given url This is a shortcut to creating an instance of glow.net.XhrRequest.
<static>  
glow.net.put(url, data, opts)
Makes an HTTP PUT request to a given url This is a shortcut to creating an instance of glow.net.XhrRequest.
Namespace Detail
glow.net
Methods for getting data & resources from other locations. Sometimes referred to as AJAX.
Method Detail
<static> glow.net.crossDomainGet(url, opts)
Cross-domain get via window.name A request made via a form submission in a hidden iframe, with the result being communicated via the name attribute of the iframe's window. The URL that's requested should respond with a blank HTML page containing JavaScript that assigns the result to window.name as a string: ``
Parameters:
{string} url
The URL to request.
{Object} opts Optional
{number} opts.timeout Optional
Time to allow for the request in seconds. No timeout is set by default.
{string} opts.blankUrl Optional, Default: '/favicon.ico'
The path of a page on same domain as the caller, ideally a page likely to be in the user's cache.

<static> glow.net.crossDomainPost(url, data, opts)
Cross-domain post via window.name A request made via a form submission in a hidden iframe, with the result being communicated via the name attribute of the iframe's window. The URL that's requested should respond with a blank HTML page containing JavaScript that assigns the result to window.name as a string: ``
Parameters:
{string} url
The URL to request.
{Object|string} data
Data to send. This can be either a JSON-style object or a urlEncoded string.
{Object} opts Optional
{number} opts.timeout Optional
Time to allow for the request in seconds. No timeout is set by default.
{string} opts.blankUrl Optional, Default: '/favicon.ico'
The path of a page on same domain as the caller, ideally a page likely to be in the user's cache.

<static> {glow.net.XhrRequest} glow.net.del(url, opts)
Makes an HTTP DELETE request to a given url. This is a shortcut to creating an instance of glow.net.XhrRequest.
			glow.net.del('myFile.html').on('load', function(response) {
				// handle response
			});
Parameters:
{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. These options are the same as the constructor options for glow.net.XhrRequest.
Returns:
{glow.net.XhrRequest}

<static> {glow.net.XhrRequest} glow.net.get(url, opts)
Makes an HTTP GET request to a given url. This is a shortcut to creating an instance of glow.net.XhrRequest.
			glow.net.get('myFile.html').on('load', function(response){
				alert( 'Got file:' + response.text() );
			}).on('error', function(response){
				alert( 'Something went wrong:' + response.text() );
			});
Parameters:
{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. These options are the same as the constructor options for glow.net.XhrRequest.
Returns:
{glow.net.XhrRequest}

<static> {glow.net.ResourceRequest} glow.net.getResources(url)
Load scripts, images & CSS. Files can be loaded from other domains. Note: Due to a cross-browser restriction, 'load' may fire before CSS files from another domain are fully loaded in Gecko browsers.
			// load a single CSS file with a callback specified
			glow.net.getResources('/styles/custom.css').on('load', function() {
				// CSS has now loaded
			});
			// load a single CSS file with a callback specified
			glow.net.getResources([
				'/imgs/whatever.png',
				'/style/screen.css',
			]).on('load', function() {
				// CSS & image now loaded
			});
			// load multiple files by specifying and array
			glow.net.getResources({
				js: ['http://www.server.com/script', 'http://www.server.com/anotherScript'],
				img: ['http://www.server.com/product4/thumb']
			}).on('progress', function(event) {
				// update a progress meter
			}).on('load', function(response){
				// files now loaded
			});
Parameters:
{string[]|string|Object} url
Url(s) to load. Urls ending in ".css" are assumed to be CSS files, Urls ending in ".js" are assumed to be JavaScript. All other files will be treated as images. You can provide an object in the form `{js: [], css: [], img: []}` to be explicit about how to treat each file.
Returns:
{glow.net.ResourceRequest}

<static> {glow.net.JsonpRequest} glow.net.jsonp(url, opts)
Fetch JSON via JSONP. This can be used cross domain, but should only be used with trusted sources as any javascript included in the script will be executed. This method only works if the server allows you to specify a callback name for JSON data. Not all JSON sources support this, check the API of the data source to ensure you're using the correct querystring parameter to set the callback name.
			glow.net.jsonp('http://twitter.com/statuses/user_timeline/15390783.json?callback={callback}', {
				timeout: 5
			}).on('load', function(data) {
				alert(data);
			}).on('error', function() {
				alert('Request timeout');
			});
Parameters:
{string} url
Url of the script. Set the callback name via the querystring to `{callback}`, Glow will replace this with another value and manage the callback internally. Check the API of your data source for the correct parameter name. Eg, in Flickr it's `jsoncallback={callback}`, in Twitter it's `callback={callback}`.
{object} opts Optional
{number} opts.timeout Optional
Time to allow for the request in seconds.
{string} opts.charset Optional
Charset attribute value for the script.
Returns:
{glow.net.JsonpRequest}

<static> {glow.net.XhrRequest} glow.net.post(url, data, opts)
Makes an HTTP POST request to a given url This is a shortcut to creating an instance of glow.net.XhrRequest.
			glow.net.post('myFile.html', {
				key: 'value',
				otherkey: ['value1', 'value2']
			}).on('load', function(response) {
				alert( 'Got file:' + response.text() );
			});
Parameters:
{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|String} data
Data to send. This can be either a JSON-style object or a urlEncoded string.
{Object} opts Optional
Options. These options are the same as the constructor options for glow.net.XhrRequest.
Returns:
{glow.net.XhrRequest}

<static> {glow.net.XhrRequest} glow.net.put(url, data, opts)
Makes an HTTP PUT request to a given url This is a shortcut to creating an instance of glow.net.XhrRequest.
			glow.net.put('myFile.html', {
				key: 'value',
				otherkey: ['value1', 'value2']
			}).on('load', function(response) {
				// handle response
			});
Parameters:
{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|String} data
Data to send. This can be either a JSON-style object or a urlEncoded string.
{Object} opts Optional
Options. These options are the same as the constructor options for glow.net.XhrRequest.
Returns:
{glow.net.XhrRequest}

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