Ajax Response Doesn't Equal What I Think It Should
I'm trying to call a displayUsers function, if response equals 'loggedIn' (response is coming from echo statement in php for ajax request). It always jumps straight to the else sta
Solution 1:
// response is an object which you get from ajex.
// You have not written how you call loginCheckResponse()
// call like loginCheckResponse(response.<variable which you return from service page>)
function loginCheckResponse(response)
{
//check response, if it is "loggedIn" then call show users function
alert(response);
if (response == "loggedIn") {
displayUsers();
} else {
alert("Login Failed. Please try again.")
}
}
Solution 2:
Changed my code to:
//logged in
function loginCheckResponse(response) {
if(response.trim()=="loggedIn"){
displayUsers();
}
else{
alert("Login Failed. Please try again.");
}
}
It now works. Thanks for the help anyway people.
Post a Comment for "Ajax Response Doesn't Equal What I Think It Should"