My PHP:
if($count == 1 && $user_level < 4 && $if_active == 1)
{
$response = array("success" => true);
//The login stuff happens here
echo json_encode($response);
}
elseif($count == 1 && $user_level < 4 && $if_active == 0)
{
$response = array("success" => not_act);
echo json_encode($response);
}
else
{
$response = array("success" => false);
echo json_encode($response);
}
The JQuery that sends and recieves the data from that PHP file
$('#login_form').submit(function(){
var emailB = encodeURIComponent($('#email_B').val());
var passwordB = encodeURIComponent($('#password_B').val());
$('#wrapper').fadeOut();
$('#login_effect').fadeIn();
$.ajax({
type: 'POST', url: 'checklogin.php', dataType: "json", data: { email: emailB, password: passwordB, },
success: function(result) {
if (!result.success) { timeout = setTimeout(function(){ $('#login_effect').fadeOut(); }, 1500); $('#wrong_password').fadeIn(); }
else if (result.success == not_act) {timeout = setTimeout(function(){ $('#login_effect').fadeOut(); }, 1500); $('#not_act').fadeIn();}
else { timeout = setTimeout(function(){ $('#login_effect').fadeOut(); }, 1500); document.location.href='http://matchmingle.net/profile/'; }
}
});
return false;
});
This works fine and dandy EXCEPT for the not activated part. How do I find out in the JQuery what the JSON returned besides just true and false? I tried to
$response = array("success" => not_act);
and then in the JQUery
else if (result.success == not_act) {do cool stuff}
but I can't get it to work because I'm obviously doing it wrong. BTW I'm very new to this JQuery/JSON/Javascript, what you're seeing me do is what I've learned from a dummies book over the corse of a few weeks and a bunch of help from you guys.
So yeah, what's the proper way to set the json response variable and find out what it's value is in the JQuery? Thanks a bunch -Mike