-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Problem is in _createAjax method:
_createAjax: function(id, o, origSuc, origCom){
var that = this;
return function(){
if(o.beforeCreate.call(o.context || that, id, o) === false){return;}
that.inProgress++;
if(that.inProgress === 1){
$.event.trigger(that.name +'AjaxStart');
}
if(o.cacheResponse && cache[id]){
if(!cache[id].cacheTTL || cache[id].cacheTTL < 0 || ((new Date().getTime() - cache[id].timestamp) < cache[id].cacheTTL)){
that.requests[id] = {};
//START OF TWEAK
var cachedData = cache[id];
//END OF TWEAK
setTimeout(function(){
that._success.call(that, o.context || o, origSuc, cachedData._successData, 'success', cachedData, o);
that._complete.call(that, o.context || o, origCom, cachedData, 'success', id, o);
}, 0);
} else {
delete cache[id];
}
}
if(!o.cacheResponse || !cache[id]) {
if (o.async) {
that.requests[id] = $.ajax(o);
} else {
$.ajax(o);
}
}
return id;
};
}
When calling method clearCache just in time when setTimeout defers funtion invocation I had "undefined" issue with cache[id] because cache was meanwhile cleared. Fix is very easy and is surrounded by commentaries:
//START / END OF TWEAK