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
});
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;