これは私の save_custLog_data.php ファイルです。
<?php
$a = $_GET['custEmail'];
$b = $_GET['pswrd'];
$file = '/home/students/accounts/s2090031/hit3324/www/data/customer.xml';
if(file_exists($file))
{
$xml = new SimpleXMLElement($file, null, true);
foreach($xml->children() as $child)
{
if((($child->EmailAddress) == $email) && (($child->Password) == $password))
{
if(isset($session))
{
$session = (string)$child->CustId;
$_SESSION['cust_id'] = $session;
echo"Welcome";
}
break;
}
else
{
echo"Invalid Email or Password!! Please Enter again";
exit();
}
}
}
else
{
echo"XML file you are trying to access doesn't exist";
}
?>
上記は私のphpページです。以下に私のhtmlページを見ることができます。ただし、埋め込まれた JavaScript 部分のみを追加します。
<script>
function validate()
{
var email = "";
var pswrd = "";
email = document.getElementById("txtEmail").value;
pswrd = document.getElementById("txtPaswrd").value;
if((email != "") && (pswrd != ""))
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var msg = xmlhttp.responseText;
if(msg == "Welcome")
{
window.location.assign("buying.htm");//this method call doesn't work
}
else
{
alert(msg);
}
}
}
xmlhttp.open("GET","save_custLog_data.php?custEmail="+email+"&pswrd="+pswrd,true);
xmlhttp.send();
}
else
{
alert("Loging form can't be empty");
}
}
</script>
私の質問は、なぜ window.location.assign("buying.htm") メソッド呼び出しが機能しないのかということです