Namespace network
Provides an interface for making ajax requests, and for bulk loading data from a set of URLs, e.g. level or tile data.
Defined in: network.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
network.bulkLoad(urls, progresscallback, timeoutcallback, timeout)
Bulk load data, e.g.
|
| <static> |
network.makeRequest(url, callback, timeout_callback, type, data, timeout)
Make a single ajax request.
|
Method Detail
<static>
network.bulkLoad(urls, progresscallback, timeoutcallback, timeout)
Bulk load data, e.g. tile or level data, from urls. Loads an array of urls and calls progresscallback(number_of_urls_left, data_received, url, all_data_loaded_from_all_calls) each time a url has finished loading. The value in number_of_urls_left is the number of urls still to be loaded, whilst data_received is the actual data loaded from a url, and url is that url. Finally, received is an associative array where the key is the url, and the value is the content at that url.
- Parameters:
- urls
- is an array of urls to fetch
- progresscallback
- is called each time a url is successfully fetched - see above for the meaning of the arguments.
- timeoutcallback
- is called if a request times out.
- timeout
- is the number of milliseconds to wait before timing out the request.
<static>
network.makeRequest(url, callback, timeout_callback, type, data, timeout)
Make a single ajax request. Returns the request object. The default timeout is 30000 milliseconds.
- Parameters:
- url
- is where to fetch data from.
- callback
- gets called when the data arrives, taking arguments (response_data, http_request).
- timeout_callback
- gets called when the request times out.
- type
- is GET or POST (note that this may default to POST on some platforms if data is passed).
- data
- is an associative array of data to send (optional).
- timeout
- is how long in milliseconds to wait before registering a network request as failed (and calling timeout_callback).
