javascript ajax要求
2631 ワード
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<input id="btn1" type="button" value=" " />
<script type="text/javascript">
var oBtn = document.getElementById("btn1");
oBtn.onclick = function () {
var oAjax = null;
if (window.XMLHttpRequest) {
oAjax = new XMLHttpRequest();
} else {
oAjax = new ActiveXObject("");
}
oAjax.open("get", "aaa.txt", true);
oAjax.send();
oAjax.onreadystatechange = function () {
if (oAjax.readyState == 4) {
if (oAjax.status == 200) {
alert(oAjax.responseText);
}
}
};
};
</script>
</body>
</html>