title: Why is my form still reseting when I submit with JavaScript?
body: <p>I am submitting a form with JavaScript.</p>
  
  <p>Here is my form:</p>
  
  <pre><code> &lt;form id="rolesSelectForm" class="stdform" action="" onsubmit="return submitForm()"&gt;
  
  &lt;p&gt;
      &lt;label&gt;Select User&lt;/label&gt;
      &lt;span class="field"&gt;
          &lt;select name="selectUser" id="selectUser"&gt;
              @foreach (var item in Model.Users)
              {
                  &lt;option value="@item.Id"&gt;@item.UserName&lt;/option&gt;
              }
          &lt;/select&gt;
      &lt;/span&gt;
  &lt;/p&gt;
  &lt;p class="stdformbutton"&gt;
      &lt;button class="submit radius2" type="submit"&gt;Save&lt;/button&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is my script:</p>
  
  <pre><code>&lt;script&gt;
  function submitForm() {
  
      var usersRoles = new Array;
      jQuery("#dualSelectRoles2 option").each(function () {
          usersRoles.push(jQuery(this).val());
      });
  
      var model = new Object();
      model.userId = jQuery('#selectUser').val();
      model.rolesList = usersRoles;
  
      console.log('model: ' + 'user: ' + model.userId + 'roles: ' + model.rolesList);
      console.log('JSON: ' + JSON.stringify(model));
  
      jQuery.ajax({
          type: "POST",
          url: "@Url.Action("AddUser")",
          dataType: "json",
          contentType: "application/json",
          data: JSON.stringify(model),
          success: function (data) { showSuccessMessage(data); },
          failure: function (errMsg) {
              alert(errMsg);
          }
      });
  }
  
  //Shows the success message
  function showSuccessMessage(data) {
      alert(data);
  }
  </code></pre>
  
  <p></p>
  
  <p>Now when I click the button, the page does refresh and I never get my alert.</p>
  
  <p>In chrome its at least makes the ajax post request but in Firefox, it just reloads the page before the post is even made.</p>
  
  <p>From what I read if I made my form return the JavaScript function, it would not reload. However this is not my case.</p>