Last active
December 18, 2015 15:19
-
-
Save suneo3476/5803534 to your computer and use it in GitHub Desktop.
【未実行】「パーフェクトJavaScript」p.294 リスト11.12 XMLHttpRequestのタイムアウト処理。テストしてない。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var xhr = new XMLHttpRequest(); | |
var timerId = window.setTimeout(function() { | |
xhr.abort(); | |
}, 5000); // 5秒 | |
xhr.onreadystatechange = function() { | |
if (request.readyState == 4) { | |
// タイムアウト処理をキャンセルする | |
window.clearTimeout(timerId); | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment