I would just like to know how to go about comparing the resulting echo from a $.ajax call in JavaScript. I attempted this and even though I get 1, it doesn't actually compare the results correctly.
jQuery:
        $.ajax({
        type: "POST",
        url: "login.php",
        data: user,
        dataType: 'html',
        success: function(result)
        {
            alert(result);
            if(result == '1')
            {
                alert("logged in :D");
                //document.location.replace('home.php');
            }
            else
            {
                alert("not logged in :<");
            }
        },
        failure: function()
        {
            alert('An Error has occured, please try again.');
        }
    });
PHP:
<?php
session_start();
$host = "localhost";
$user = "root";
$passw = "";
$con = mysql_connect($host, $user, $passw);
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}
$json = $_REQUEST['json'];
$json = stripslashes($json);
$jsonobj = json_decode($json);
$password = $jsonobj->password;
$email = $jsonobj->email;
mysql_select_db("tinyspace", $con);
$result = mysql_query("SELECT 1 FROM users WHERE email = '"
                    . $email . "' AND password = '" . $password . "'");
 while($info = mysql_fetch_array( $result )) 
 { 
    if($info[0] == 1)
    {
        echo '1';
    }
}
 ?> 
 
     
     
    