I have made my own AJAX Login. but the script seems to redirect to the php page itself rather than submitting it through AJAX
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-1.9.0.min.js"></script>
<script type="text/javascript">
var form = $('#loginform');
form.submit(function (ev) {
ev.preventDefault();
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize(),
success: function (data) {
alert('ok');
}
});
});
</script>
</head>
<body>
<form method="post" action="functions/fn_login.php" id="loginform">
<input type="email" placeholder="Email / Mobile No." required name="email">
<input type="password" placeholder="Password" required name="password">
<input type="submit" id="submit" value="Submit">
</form>
<div id="user-result"></div>
</body>
</html>
Anything wrong with my code?