I'm making a user login system. When the user submits the form the AJAX request is not working and the page changes 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 return false is not working