I created a login for my application, but I'm having a problem with the return. The user and password panel sends the request to the php login (which accesses the bank). The return is an 'OK', which should be validated in the code below:
$('#btnLogin').click(function(){
var login = $('#inputEmail').val();
var senha = $('#inputPassword').val();
$.post('_class/login.php',{inputEmail: login, inputPassword: senha}, function(data){
console.log(data);
if(data === 'OK'){
location.reload();
}else{
$('#myModal').modal('show');
}
});
});
Problem: Return is accepting 'OK' but does not open the home screen and still returns the incorrect login message (myModal). After you clear the error message, when you reload the page (F5), the system opens the home. How can I fix this?
editing -----------------
Eduardo, I'm using the codes: html
$('#btnLogin').click(function(){
var login = $('#inputEmail').val();
var senha = $('#inputPassword').val();
$.post('_class/login.php',{inputEmail: login, inputPassword: senha}, function(data){
//console.log(data);
var response = $.trim(data);
if(data === 'OK'){
location.reload(true);
}else{
$('#myModal').modal('show');
}
});
});
<form class="vertical-form" id="new_user" action="_class/login.php" accept-charset="UTF-8" method="post"><legend>
Acesso
</legend>
<input placeholder="Email" label="false" type="text" name="inputEmail" id="inputEmail" />
<input placeholder="Senha" label="false" autocomplete="off" type="password" name="inputPassword" id="inputPassword" />
<input type="button" id="btnLogin" name="commit" value="Acessar" />
<!-- <input type="submit" name="commit" value="Acessar" /> -->
<p><a style="cursor: pointer;" data-toggle="modal" data-target="#myModal2">Esqueceu sua senha?</a></p>
</form>