title: Why Ajax post request is executed several times?
body: <p>here is my code:</p>
  
  <pre><code>$(document).ready(function(){
              $("#mainbutton").click(function(){
                  $("#ajaxform").submit(function(e){
                      var info = $(this).serialize();
                      $.ajax(
                      {
                          url : "userctrl",
                          type: "post",
                          data : info,
                          success:function(data, textStatus, jqXHR) 
                          {
                              console.log("success");
                               $('.valid-error').html(data);
                          },
                      });
                      e.preventDefault()
                  });
                  $("#ajaxform").submit(); //Submit the form
              });
          });
  </code></pre>
  
  <p>and my html</p>
  
  <pre><code>        &lt;form id="ajaxform"&gt;
          &lt;input type="hidden" name="action" value="submit"/&gt;
          &lt;input type="text" placeholder="Name" name="name" id="name" /&gt;&lt;span&gt;&lt;/span&gt;
          &lt;input type="text" placeholder="Surname" name="surname" /&gt;&lt;span&gt;&lt;/span&gt;
          &lt;input type="text" placeholder="Address" name="address" /&gt;&lt;span&gt;&lt;/span&gt;
          &lt;p class="valid-error"&gt;&lt;/p&gt;
          &lt;input id="mainbutton" class="mainbutton" type="button" value="trial"/&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>this request is executed several times depend on which fields is filled. If I fill two fields will be executed 3 times if I fill 3 fields 4 times. This is not always the case but definitely my doPost method in the servlet is called several times .... I click on the submit button only once !!! Why ?</p>