Fix timeouts
Showing
1 changed file
with
5 additions
and
13 deletions
... | @@ -42,20 +42,12 @@ | ... | @@ -42,20 +42,12 @@ |
42 | request.withCredentials = true; | 42 | request.withCredentials = true; |
43 | } | 43 | } |
44 | if (options.timeout) { | 44 | if (options.timeout) { |
45 | if (request.timeout === 0) { | 45 | abortTimeout = window.setTimeout(function() { |
46 | request.timeout = options.timeout; | 46 | if (request.readyState !== 4) { |
47 | request.ontimeout = function() { | ||
48 | request.timedout = true; | 47 | request.timedout = true; |
49 | }; | 48 | request.abort(); |
50 | } else { | 49 | } |
51 | // polyfill XHR2 by aborting after the timeout | 50 | }, options.timeout); |
52 | abortTimeout = window.setTimeout(function() { | ||
53 | if (request.readyState !== 4) { | ||
54 | request.timedout = true; | ||
55 | request.abort(); | ||
56 | } | ||
57 | }, options.timeout); | ||
58 | } | ||
59 | } | 51 | } |
60 | 52 | ||
61 | request.onreadystatechange = function() { | 53 | request.onreadystatechange = function() { | ... | ... |
-
Please register or sign in to post a comment