2013-05-03 65 views
0

每次我尝试发布或使用从我的文件index.php获取通过Ajax函数POST或GET调用Ajax_mysql.php我得到一个内部500错误。服务器没有提供任何其他错误。我已经包含了我的JavaScript函数,它调用了服务器端的php。内部500错误有史以来发布或获得Ajax

function submit_login() { 
    if(document.form.loggedIn.checked) return 
    request = new XMLHttpRequest() 
    request.onreadystatechange = respond_login 
    request.open("POST", "Ajax_mysql.php", true) 
    request.send("action=login&password=" + postEscape(document.form.pwd.value) + 
        "&username=" + postEscape(document.form.user.value)) 
    document.form.pwd.value = "" 
    document.form.user.value = "" 
} 

腓Ajax_mysql.php:

<?php 
$password_test = "fcb"; 
$username_test = "ben"; 
$action = $_POST['action']; 
$username = $_POST['username']; 
$password = $_POST['password']; 
//Testing against hardcoded username and password 
if ($username != $username_test) 
{ 
//output the response 
$response = "failed" 
echo $response; 
} 
?> 
+2

忘了注释掉'测试对硬编码的用户名和password' – Joseph 2013-05-03 03:06:46

+4

有一个错字太多 - '$ responce' VS'$ response'。 – 2013-05-03 03:07:25

+2

在你真实的服务器代码中,“对硬编码的用户名和密码进行测试”行实际评论过? – 2013-05-03 03:07:41

回答

1
$responce = "failed" //miss ; 
echo $response;  // typo $responce;