I\'m new to JQuery and attempting to write a script to check username availability. My problem is that no matter what I type, I always get back \"This username is already in
Try changing the PHP source to return "1" or "0":
include('database_connection.php');
if (isset($_POST['username'])) {
$username = mysql_real_escape_string($_POST['username']);
$check_for_username = mysql_query("SELECT user_id FROM users WHERE username='$username'");
if (mysql_num_rows($check_for_username)) {
echo "TRUE";
} else {
echo "FALSE"; //No Record Found - Username is available
}
}
?>
and then change your JS to parse that as an integer:
success:
function(msg) {
isSuccess = parseInt(msg);
}