I discovered an interesting problem with an echoed value from an AJAX request of JQuery, which I don't have an answere for:
My data == "LOCKED"
never returns true (line 13)!
JQuery -> AJAX call on button-click:
$.ajax({
url: "ajax/login_ajax_call.php",
method: "POST",
data: { user: usr, password: pwd }
}).done(function(data){
if(data == true || data == "true"){ // -> this works with data beeing true (bool) or "true" (string)
$("#form_submit").submit();
}
else{
console.log(jQuery.type(data)); // -> (string)
console.log(data); // -> "LOCKED"
console.log(jQuery.type("LOCKED")); // -> (string)
if(data == "LOCKED"){ // also tried "===" but it never returns true
[...]
}
else{
[...]
}
}
});
});
PHP(1) -> gets a value returned by a Class(PHP(2)):
include_once("../Classes/Login_check.php");
$lih = new Login_check();
$result = $lih -> check($_POST["user"], $_POST["password"]);
var_dump($result); // -> string(6) "LOCKED"
echo $result;
PHP(2, "Login_check.php"):
[...]
// also tried:
// $test = "LOCKED";
// var_dump($test); // -> string(6) "LOCKED"
// return $test;
return "LOCKED";
[...]
Tell me if you need further informations! I hope anyone know what causes this problem!