Permalink
Browse files

Queue callbacks while requesting

  • Loading branch information...
1 parent b2139ff commit bb7cb20ddb7ee798f7f2a8179f49ecada6d5d2fe @joeflateau committed Apr 9, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/jquery.offline.js
View
@@ -48,18 +48,17 @@
var requestingKey = url + "?" + $.param(data || {});
if (requesting[requestingKey]) {
+ requesting[requestingKey].push(fn);
return false;
}
- requesting[requestingKey] = true;
+ requesting[requestingKey] = [fn];
return jQuery.ajax({
type: "GET",
url: url,
data: data,
success: function(responseData, text) {
- delete requesting[requestingKey];
-
// handle lack of response (error callback isn't called in this case)
if (undefined === responseData) {
if (!window.navigator.onLine) {
@@ -71,9 +70,11 @@
return;
}
- fn(responseData, text);
+ $.each(requesting[requestingKey], function (i, fn) {
+ fn(responseData, text);
+ });
},
- error: function() {
+ complete: function() {
delete requesting[requestingKey];
},
dataType: "json",

0 comments on commit bb7cb20

Please sign in to comment.