From 02838540dba71a62423beec482d1d969144fba1e Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Fri, 7 Oct 2011 19:29:04 +0000 Subject: [PATCH] don't call callbacks of cancelled requests --- source/Ox.UI/js/Core/Ox.Request.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/Ox.UI/js/Core/Ox.Request.js b/source/Ox.UI/js/Core/Ox.Request.js index 8b801a69..d4edf639 100644 --- a/source/Ox.UI/js/Core/Ox.Request.js +++ b/source/Ox.UI/js/Core/Ox.Request.js @@ -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) {