Skip to content

Commit 0af9c29

Browse files
authored
Merge pull request #132 from acple/fix-script-stuck
Fix the script got stuck when request timed out
2 parents 226c80e + a9f87ec commit 0af9c29

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Affjax.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ exports._ajax = function () {
5353
errback(e);
5454
}
5555
}
56-
xhr.onerror = function () {
57-
errback(new Error("AJAX request failed: " + options.method + " " + options.url));
56+
var onerror = function (msg) {
57+
return function () {
58+
errback(new Error(msg + ": " + options.method + " " + options.url));
59+
};
5860
};
61+
xhr.onerror = onerror("AJAX request failed");
62+
xhr.ontimeout = onerror("AJAX request timed out");
5963
xhr.onload = function () {
6064
callback({
6165
status: xhr.status,

0 commit comments

Comments
 (0)