From 19be508afe3eeb78cc6a5e767b9f2b0498899af1 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 2 Jan 2016 15:09:28 +0530 Subject: [PATCH] Fix pending requests: depend on data not id. --- source/UI/js/Core/Request.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/source/UI/js/Core/Request.js b/source/UI/js/Core/Request.js index fd837f1d..d8b1f331 100644 --- a/source/UI/js/Core/Request.js +++ b/source/UI/js/Core/Request.js @@ -120,10 +120,8 @@ Ox.Request = (function() { data: options.data }); - if (pending[options.id]) { - setTimeout(function() { - Ox.Request.send(options); - }); + if (pending[req]) { + wait(); } else { requests[options.id] = { url: options.url, @@ -138,7 +136,7 @@ Ox.Request = (function() { callback(data, true); }); } else { - pending[options.id] = true; + pending[req] = true; $.ajax({ beforeSend: function(request) { var csrftoken = Ox.Cookies('csrftoken'); @@ -207,7 +205,17 @@ Ox.Request = (function() { } else { callback(data, false); } - pending[options.id] = false; + delete pending[req]; + } + + function wait() { + setTimeout(function() { + if (pending[req]) { + wait(); + } else { + Ox.Request.send(options); + } + }); } return options.id;