don't call callbacks of cancelled requests

This commit is contained in:
rlx 2011-10-07 19:29:04 +00:00
parent 851aa386c0
commit 02838540db

View file

@ -115,7 +115,10 @@ Ox.Request = function(options) {
url: options.url,
data: options.data
};
if (cache[req] && (options.age == -1 || options.age > Ox.getTime() - cache[req].time)) {
if (cache[req] && (
options.age == -1
|| options.age > +new Date() - cache[req].time
)) {
setTimeout(function() {
callback && callback(cache[req].data);
}, 0);
@ -134,9 +137,10 @@ Ox.Request = function(options) {
}
function callback(data) {
delete requests[options.id];
//Ox.len(requests) == 0 && $body.trigger('requestStop');
options.callback && options.callback(data);
if (requests[options.id]) {
delete requests[options.id];
options.callback && options.callback(data);
}
}
function debug(request) {