目标:
如果验证正确或失败,则启用显示弹出窗口。
问题:
不知怎的,它不想做一个 验证密码。
我尝试使用Firebug,但由于某种原因无法对此代码进行调试。
在创建此验证之前,我之前有过这段代码:
function validation() {
if (mittXHRobjekt.readyState == 4)
alert("Okey");
}
通过添加验证进行更多改进后,readyState无法正常工作。我所做的只是改进功能验证。
验证的当前代码是:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled 1</title>
<script type="text/javascript">
var mittXHRobjekt = null;
function skapaXHRobjekt() {
try {
XHRobjekt = new XMLHttpRequest();
} catch (err1) {
try {
XHRobjekt = new ActiveXObject("Microsoft.XMLHTTP");
} catch (err2) {
try {
XHRobjekt = new ActiveXObject("Msxml2.XMLHTTP");
} catch (err3) {
XHRobjekt = false;
}
}
}
return XHRobjekt;
}
function validation() {
if (mittXHRobjekt.readyState == 4) {
if (window.document.frmPassword.txtPassword.value == mittXHRobjekt.responseText) {
alert("Correct password");
}
else {
alert("Wrong password");
}
}
alert("no ready state 4");
}
function test(url) {
mittXHRobjekt = skapaXHRobjekt();
if (mittXHRobjekt) {
mittXHRobjekt.onreadystatechange = validation;
mittXHRobjekt.open("GET", url);
mittXHRobjekt.send(null);
}
}
</script>
</head>
<body>
<form id="frmPassword">
<input name="txtPassword" type="password" />
<input name="btnPassword" type="button" value="Evaluation" onclick="test('password.txt')" />
</form>
</body>
</html>