1
I created a login for my application, but I’m having trouble returning. The user and password panel sends the request to php login (which accesses the database). 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: the return is accepting the 'OK', but does not open the home screen and still returns the incorrect login message (myModal). After deleting the error message, while reloading the page (F5), the system opens the home. How can I fix this?
editing-----------------
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>
Eduardo, vlw the hint...but I’m still in it. I tried to use the hint on both ends. The code is problematic in the page’s Reload.... I think. Still showing invalid login notice, but if press F5...loads home.
– andre
Ah, if that’s the problem, try using
history.go(0);
orwindow.location.href = window.location.href;
in place oflocation.reload();
. If you prefer, try to put a true inlocation.reload( true );
. Check it out and update your post with your attempts.– StillBuggin
guy, I edited and includes the html and javascript codes...I’m still in the same...
– andre