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|
network.bulkLoad(urls, progresscallback, timeoutcallback, timeout)
Bulk load data, e.g.
network.makeRequest(url, callback, timeout_callback, type, data, timeout)
Make a single ajax request.
<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.
- is an array of urls to fetch
- is called each time a url is successfully fetched - see above for the meaning of the arguments.
- is called if a request times out.
- 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.
- is where to fetch data from.
- gets called when the data arrives, taking arguments (response_data, http_request).
- gets called when the request times out.
- is GET or POST (note that this may default to POST on some platforms if data is passed).
- is an associative array of data to send (optional).
- is how long in milliseconds to wait before registering a network request as failed (and calling timeout_callback).