Reputation: 15372
When I call this ajax function, the object data
prints out to the chrome console just fine:
$.ajax({
type: "POST",
cache: false,
url: "login_user.php",
data: "username=" + username + "&password=" + password + "&remember=" + remember,
dataType: "json",
success: function (data) {
if (data == "FALSE") {
$('#input_password').val("");
alert("The username or password you have entered is incorrect.");
return false;
}
console.log(data);
console.log(data.accepted_terms);
//always alerts 'not accepted'
if (data.accepted_terms == "TRUE") {
alert('accepted!');
} else {
alert('not accepted');
}
}
});
The undefined is the result of console.log(data.accepted_terms);
The php file being referenced returns this object with json_encode($login_info_array)
.
Am I incorrectly handling this returned object? Thanks for the help!
Upvotes: 1
Views: 95