我刚学AJAX,下面的HTML文件不行。每次我释放一个键时,萤火虫都会说“登录不是一个功能”。我不明白为什么会这样。任何帮助表示赞赏。
<html>
<head>
<title>Ajax</title>
<script type="text/javascript">
function makeAjax() {
var ajax;
try{
ajax = new XMLHttpRequest();
}
catch (e) {
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser is either OLD or BAD! UPDATE!");
return false;
}
}
}
ajax.onreadystatechange = function() {
if(ajax.readyState == 4 && ajax.status == 200) {
document.getElementById("btag").innerHTML = ajax.responseText;
}
}
}
function login() {
ajax.open("GET", "ajax.php", true);
ajax.send(null);
}
</script>
</head>
<body onLoad="makeAjax();">
<form name="login">
Username: <input type="text" onKeyUp="login();" />
<br /><br />
Password: <input type="password" onKeyUp="login();" />
<b id="btag"></b>
</form>
</body>
</html>