Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Jquery Ajax POST method using GET instead of POST?

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?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!