2
* @author Patrick Schmiedel patrick.schmiedel@gmx.net
6
* @classDescription Static class. Keeps a cache of retrieved urls.
8
var AjaxRequestWrapper = Class.create();
10
AjaxRequestWrapper.cache = {};
13
* @classDescription Wraps a GET url request to contain state
14
* information like the url, and simplifies the use by setting some
16
* TODO: Create a non-cached version for retrieving data that is
19
AjaxRequestWrapper.getCached = Class.create();
21
AjaxRequestWrapper.getCached.prototype = {
23
* @constructor Creates a new instance and processes the request.
24
* @param {String} url The url to retrieve.
25
* @param {Function} callback The function that handles the retrieved data.
27
initialize: function(url, callback) {
30
this.callback = callback;
31
this.arguments = $A(arguments).slice(2);
35
if (AjaxRequestWrapper.cache[url]) {
36
callback.apply(null, $A([AjaxRequestWrapper.cache[self.url]]).concat(self.arguments));
38
var onSuccess = function(transport) {
39
AjaxRequestWrapper.cache[self.url] = transport.responseText;
40
callback.apply(null, $A([AjaxRequestWrapper.cache[self.url]]).concat(self.arguments));
43
var onFailure = function(transport) {
44
Debug.ajaxFailure(transport, self.url);