Ok so i have this html login page for a test website:
<body>
<div class = "container-login">
<form class ="devbook-form" id ="login">
<span>
Welcome to Devbook!
</span>
<div>
<input type="text" name="email" id="email" placeholder="email" required="required">
</div>
<div>
<input type="password" name="password" id="password" placeholder="password" required="required">
</div>
<a href="/register">Register Here</a>
<button type="submit" class="btn-devbook">Login</button>
</form>
</div>
<script src="/assets/js/jquery.min.js" ></script>
<script src="/assets/js/login.js"></script>
</body>
</html>
The scripts calls for the js responsible for communication with an API, but it simply doesnt start the Ajax, or the Ajax is working in the wrong way, but must probably it doesnt start the Ajax cause i tried to put a console.log("Testing") in the button but the consoles gives nothing. I have another ajax button for another html page which works perfectly, why is that?
This is the Ajax Jquery i'm using to get the form for a login button:
$('#login').on('submit', loginAccount);
function loginAccount(event){
event.PreventDefault();
$.ajax({
url:"/login",
method:"POST",
data: {
email: $('#email').val(),
password: $('#password').val(),
}
}).done(function() {
window.location = "/home";
}).fail(function() {
alert("Invalid email or password");
});
}
All this is meant to communicate with an API working on localhost:3000, which was made with Golang using GIN framework, it has an public.POST("/login", controllers.LoginAccount) which is meant to communicate with another API. The html page, jquery ajax and register golang function all works, but the login it doesnt, it always performs a GET instead of a POST, why is that?