dan0
12-01-2008, 07:56 PM
My ajax callback function is supposed to determine if the submitted argument is 'Login Successful' and if not perform an alert. However, regardless if the submitted arguement is 'Login Successful' or not the callback function displays an alert.
I have php code that upon verification of the correct email and password combination, echos 'Login Sucessful' otherwise echoes 'Login Failure'. I know my php code is correct, because when I change the callback function to simply alert the responseText either Login Successful or Login Failure is shown depending on whether I submit the correct email/password combo in the login form.
Below are my php and js code. Can someone take a look and tell me where my code is wrong? Thanks.
if ($password == $registered['password']){
session_start();
$_SESSION["userName"] = $registered['userName'];
$_SESSION["sessionId"] = session_id();
echo ('Login Successful');
} else {
echo ('Login Failure');
} // end if
function callback(ajaxResponse){
if (ajaxResponse == "Login Successful"){
window.location = "home.html";
} else {
alert('Login Error');
} // end if
} // end callback
I have php code that upon verification of the correct email and password combination, echos 'Login Sucessful' otherwise echoes 'Login Failure'. I know my php code is correct, because when I change the callback function to simply alert the responseText either Login Successful or Login Failure is shown depending on whether I submit the correct email/password combo in the login form.
Below are my php and js code. Can someone take a look and tell me where my code is wrong? Thanks.
if ($password == $registered['password']){
session_start();
$_SESSION["userName"] = $registered['userName'];
$_SESSION["sessionId"] = session_id();
echo ('Login Successful');
} else {
echo ('Login Failure');
} // end if
function callback(ajaxResponse){
if (ajaxResponse == "Login Successful"){
window.location = "home.html";
} else {
alert('Login Error');
} // end if
} // end callback