1
I’m doing a user login system. When the User makes the form Ubmit the AJAX request is not working and the page switches to login.php
JS
$("form").submit(function() {
if ($("#login_username").value() != "" && $("#login_password").value() != "") {
$.ajax({
url: $("#login-form").attr('action'), //login.php
data: $("#login-form :input").serializeArray(),
method: $("#login-form").attr('method'), //post
success: function(data) {
alert(data);
}
});
}
else {
$("#text-login-msg").text("Digite o Usuário e senha").css('color', 'red');
}
return false;
});
It seems that the Return false is not working
It seems to be javascript errors. I think the
atr()
must beattr()
– rray
even after correcting the errors of
atr()
keeps making the same mistakes– Estêvão Silva
What error? vc need to turn on the error console in one’s browser
F12
ai.– rray
I managed to fix the error, it was some syntax error in IF
– Estêvão Silva
with jquery is
val()
in place ofvalue()
– rray