このコードにはリンクに関連したエラーがあり、ページが開かれていません。私が与えているリンクにエラーがあり、それが表示されません他のページのデータを持っています。私のパソコンでは、ファイルのリンクは "D:\ xampp \ htdocs \ cart \ welcome.php"というフォルダを "D:\ xampp \ htdocs \ cart"それを右にし、私はあなたがWebサーバを実行して、あなたの解像度を要求する必要がwebstieajaxを使って表示新しいウィンドウが開きます
<html>
<head>
<script>
function check(form) {
if (form.email.value == "[email protected]") {
document.getElementById("displayu").innerHTML ="correct username".fontcolor("green");
} else if (form.email.value == "") {
document.getElementById("displayu").innerHTML ="<font color='red'>blank username</font>";
} else if (form.email.value != "") {
var email = document.getElementById('email');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
document.getElementById("displayu").innerHTML ="Please provide a valid email address";
}
else {document.getElementById("displayu").innerHTML ="wrong email";}
}
if (form.pswrd.value == "123") {
document.getElementById("displayp").innerHTML ="correct password";
} else if (form.pswrd.value == "") {
document.getElementById("displayp").innerHTML ="<span style='color:red'>blank password</span>";
}
else {document.getElementById("displayp").innerHTML ="wrong password";}
makeRequest('http://D:/xampp/htdocs/cart/welcome.php');
}
function makeRequest(url) {
httpRequest = new XMLHttpRequest();
if (!httpRequest) {
alert('Giving up :(Cannot create an XMLHTTP instance');
return false;
}
httpRequest.onreadystatechange = alertContents;
httpRequest.open('GET', url);
httpRequest.send();
}
function alertContents() {
if (httpRequest.readyState === XMLHttpRequest.DONE) {
if (httpRequest.status === 200) {
alert(httpRequest.responseText);
\t \t document.open();
document.write(httpRequest.responseText);
document.close();
} else {
alert('There was a problem with the request.');
}
}
}
</script>
</head>
<body>
<h1>for login</h1>
<h3>[email protected] and password=123</h3>
<form name="login">
<div id="displayu"></div>
<div id="displayp"></div>
Username <input type="text" name="email" id="email" />
Password <input type="password" name="pswrd"/>
<input type="button" onclick="check(this.form)" value="Login" />
<input type="reset" value="reset"/>
</form>
</body>
</html>
http:// D:/ xampp/htdocs/cart/welcome.php'は有効なURLではありません。 Webサーバーとファイルシステムは2つの非常に異なるものです。 – David
'' http:// D:/ xampp/htdocs/cart/welcome.php ''これを' 'file:/// D:/ xampp/htdocs/cart/welcome.php' 'に変更します。 '絶対パス'または '絶対パス'を提供する必要があります。 '相対リンク 'を提供することがベストプラクティスです。 –
それのためのフィドラーを作成して、別の人があなたのバグを追跡するのは簡単です。 –