Fix pending requests: depend on data not id.
This commit is contained in:
parent
b0853447d1
commit
19be508afe
1 changed files with 14 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue