Created
June 17, 2013 19:01
-
-
Save suneo3476/5799367 to your computer and use it in GitHub Desktop.
【未解決】同期通信のXMLHttpRequest。
Firefoxだと「NS_ERROR_FAILURE: Failure」
Chromeだと「Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101 」
かと言って同期通信するケースって殆ど無いし、ユーザビリティ下げるしなぁ。
解決方法知っとくべきなのかなぁ。誰か知ってたら教えて。
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
<!DOCTYPE HTML5> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<div>This is test for XMLHttpRequest.</div> | |
<script> | |
var xhr = XMLHttpRequest(); | |
xhr.open('GET', 'http://suneo3476.net', false); // 第三引数にfalseを指定して同期通信する | |
xhr.send(null); // ここでクライアント側の処理は待機となる | |
// ここにくるときはレスポンスの受信は完了している | |
xhr.setRequestHeader('IF-Modified-Since', 'Thu, 01, Jun 1970 00:00:00 GMT'); | |
if (xhr.status == 200) { | |
alert(xhr.responseText); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment