I am returning a string form php and compare it with another string in jQuery. I am 100% certain that the strings do match (well, at least are of the same value...), but still my if-clause thinks otherwise.
This is the part of my php-script that sets the returning value:
if (!$result){
echo "false";
exit();
}
This is my jQuery that performs the matching:
$.post("registeraccount.php",$(this).serialize(),function(msg){
//alert the response from the server
alert(msg + " = " + (msg == "false"));
if(msg == "false"){
$("#adminarea").html("Error");
}else{
$("#adminarea").html("Success");
}
});
No matter that the strings are equal or not equal, it's always "Success" that is printed on the web page.
In the alert I get the following result "false = false". Hence, (msg == "false") is false.
How come the strings are not true when they are equal and how do I fix it?
msg?