Update: Problem solved, I had used a wrong character encoding.
I'm trying to build a login for a web application. The process is as follows:
The problem occurs at step three. Only if the response is "missingAuthField", the wanted action happens, but if the response is e.g. "unknownUser", nothing happens.
By the way: I'm using jQuery 1.10.2 and the material-design 1.5 library in my project.
The relevant function:
mywebapp.authenticate = function (){
var user = $("#t_auth_user").val();
var pass = $("#t_auth_pass").val();
$("#loading").removeClass("hidden");
$("#hint_auth").text("");
$.ajax("backend/auth.php", {
cache: false,
method: "POST",
data: {
"user": user,
"pass": pass
},
success: function (resp){
console.log(resp); // console output works fine with each response
switch(resp){
case "missingAuthField":
$("#hint_auth").text("not everything entered");
break;
case "unknownUser":
$("#hint_auth").text("unknown user");
break;
case "wrongPassword":
$("#hint_auth").text("wrong pass");
break;
case "successful":
document.location.reload();
break;
};
},
error: function (e, type){
// my default error handling
}
});
};
Thanks for every answer!
~ Erik