Skip to content

Commit

Permalink
handle empty http response; requeue request if we are offline
Browse files Browse the repository at this point in the history
  • Loading branch information
bts authored and wycats committed Jul 9, 2010
1 parent 75bc481 commit fee75e3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/jquery.offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,21 @@
type: "GET",
url: url,
data: data,
success: function(data, text) {
success: function(responseData, text) {
delete requesting[requestingKey];
fn(data, text);

// handle lack of response (error callback isn't called in this case)
if (undefined === responseData) {
if (!window.navigator.onLine) {
// requeue the request for the next time we come online
mostRecent = function() {
getJSON(url, data, fn);
};
}
return;
}

fn(responseData, text);
},
error: function() {
delete requesting[requestingKey];
Expand Down

0 comments on commit fee75e3

Please sign in to comment.