Fix pending requests: depend on data not id.

This commit is contained in:
j 2016-01-02 15:09:28 +05:30
parent b0853447d1
commit 19be508afe

View file

@ -120,10 +120,8 @@ Ox.Request = (function() {
data: options.data data: options.data
}); });
if (pending[options.id]) { if (pending[req]) {
setTimeout(function() { wait();
Ox.Request.send(options);
});
} else { } else {
requests[options.id] = { requests[options.id] = {
url: options.url, url: options.url,
@ -138,7 +136,7 @@ Ox.Request = (function() {
callback(data, true); callback(data, true);
}); });
} else { } else {
pending[options.id] = true; pending[req] = true;
$.ajax({ $.ajax({
beforeSend: function(request) { beforeSend: function(request) {
var csrftoken = Ox.Cookies('csrftoken'); var csrftoken = Ox.Cookies('csrftoken');
@ -207,7 +205,17 @@ Ox.Request = (function() {
} else { } else {
callback(data, false); 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; return options.id;