Skip to content

Instantly share code, notes, and snippets.

@suneo3476
Last active December 18, 2015 14:39
Show Gist options
  • Save suneo3476/5799160 to your computer and use it in GitHub Desktop.
Save suneo3476/5799160 to your computer and use it in GitHub Desktop.
【未解決】XMLHttpRequestのサンプル。いまいち成功しているかどうかが分からない。少なくともalertは出ないし…
<!DOCTYPE HTML5>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div>This is test for XMLHttpRequest.</div>
<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://suneo3476.net');
xhr.setRequestHeader('IF-Modified-Since', 'Thu, 01, Jun 1970 00:00:00 GMT');
xhr.send(null);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
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