Skip to content

Commit

Permalink
Merge pull request #132 from acple/fix-script-stuck
Browse files Browse the repository at this point in the history
Fix the script got stuck when request timed out
  • Loading branch information
garyb committed Feb 9, 2019
2 parents 226c80e + a9f87ec commit 0af9c29
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Affjax.js
Expand Up @@ -53,9 +53,13 @@ exports._ajax = function () {
errback(e);
}
}
xhr.onerror = function () {
errback(new Error("AJAX request failed: " + options.method + " " + options.url));
var onerror = function (msg) {
return function () {
errback(new Error(msg + ": " + options.method + " " + options.url));
};
};
xhr.onerror = onerror("AJAX request failed");
xhr.ontimeout = onerror("AJAX request timed out");
xhr.onload = function () {
callback({
status: xhr.status,
Expand Down

0 comments on commit 0af9c29

Please sign in to comment.