title: Why does my jQuery code POST return a query string in my URL?
body: <p>So I've followed some guides online and made a simple jQuery POST.</p>
  
  <pre><code>$("#btnLogin").click(function () {
      var username = $("#username").val();
      var password = $("#password").val();
      $.ajax({
          type: "POST",
          url: "http://localhost:8080/OhSnip/api/users/",
          dataType: "application/x-www-form-urlencoded",
          data: {
              username: username,
              password: password,
          },
          success: function(result) {
              console.log(result);
          }
  
      })
  });
  </code></pre>
  
  <p>However, whenever I click the login button, the page returns a query string and completely ignores the success function, writing nothing on the console.</p>
  
  <pre><code>http://localhost:8080/OhSnip/?username=username&amp;password=password.
  </code></pre>
  
  <p>Why does this happen?</p>
  
  <p>I've tried many different formats and whatnot, but I have been unable to solve this issue by myself so far.</p>
  
  <p>Tutorials on youtube aren't really helping either.</p>
  
  <p><a href="https://i.stack.imgur.com/xF5td.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xF5td.png" alt="the backend works fine"></a></p>
  
  <p>The backend works fine, as you can see from the picture above, but here's the code anyway</p>
  
  <pre><code>@POST
  @Consumes("application/x-www-form-urlencoded")
  @Produces(MediaType.APPLICATION_JSON)
  public User logIn(
          @FormParam("username") String username,
          @FormParam("password") String password) {
  
      UserManager um = UserManager.getInstance();
  
      return um.logIn(username, password);
  }   
  </code></pre>
  
  <p>Anyway, thanks.</p>
  
  <p>EDIT: Form html code.</p>
  
  <pre><code>&lt;form id="logIn" action=""&gt;
       &lt;div class='form-group'&gt;
            &lt;label for='username' class='sr-onl'&gt;Username&lt;/label&gt;
            &lt;input id='username' type='username' required='' placeholder='Username' class='form-control' name='username'&gt;
      &lt;/div&gt;
      &lt;div class='form-group'&gt;
            &lt;label for='password' class='sr-onl'&gt;Password&lt;/label&gt;
            &lt;input id='password' type='password' required='' placeholder='Password' class='form-control' name='password'&gt;
      &lt;/div&gt;
      &lt;div class='form-group'&gt;
           &lt;button id="btnLogin" class='btn btn-block'&gt;Login&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>