title: Universal form submitting function for all forms in a page
body: <p>I'm trying to write a universal jquery function to submit all forms in a table when their submit button is clicked.</p>
  
  <p>What I've got so far is this:</p>
  
  <pre><code>&lt;div class="tabelaportes"&gt;
                  &lt;div class="galltitle"&gt;Tabela de Portes de Envio&lt;/div&gt;
              &lt;table cellpadding="0" cellspacing="0" border="1"&gt;
              &lt;tr&gt;
                  &lt;td class="tdleft"&gt;Peso inicial (kg) &lt;/td&gt;
                  &lt;td class="tdleft"&gt;Peso final (kg) &lt;/td&gt;
                  &lt;td class="tdleft"&gt;Valor (&amp;euro;) &lt;/td&gt;
                  &lt;td class="tdleft"&gt;Acção&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="tdright"&gt;
                      1.00 kg
                  &lt;/td&gt;
                  &lt;td class="tdright"&gt;
                      2.00 kg
                  &lt;/td&gt;
                  &lt;td class="tdright"&gt;
                      3.00 &amp;euro;
                  &lt;/td&gt;
                  &lt;td class="tdright"&gt; 
                      &lt;form method="post"&gt;
                      &lt;input type="hidden" name="kgid" value="34"/&gt;
                      &lt;input type="submit" name="rmkgid" value="Remover"/&gt;
                      &lt;/form&gt;
                  &lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class="tdright"&gt;
                      3.00 kg
                  &lt;/td&gt;
                  &lt;td class="tdright"&gt;
                      4.00 kg
                  &lt;/td&gt;
                  &lt;td class="tdright"&gt;
                      5.00 &amp;euro;
                  &lt;/td&gt;
                  &lt;td class="tdright"&gt; 
                      &lt;form method="post"&gt;
                      &lt;input type="hidden" name="kgid" value="56"/&gt;
                      &lt;input type="submit" name="rmkgid" value="Remover"/&gt;
                      &lt;/form&gt;
                  &lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;
              &lt;form method="post"&gt;
                  &lt;td&gt;
                      &lt;input type="text" name="kg_i"/&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type="text" name="kg_f"/&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type="text" name="kg_p"/&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type="submit" name="addprice" value="Adicionar"/&gt;
                  &lt;/td&gt;
                  &lt;/form&gt;
                  &lt;/tr&gt;
  
              &lt;/table&gt;
              &lt;/div&gt;&lt;script&gt;
  function submitPortes() {
      var siteurl = window.location.href;
      $("form").submit(function(sp) {
          //get form values
          var submitname = $(this).parents("tr").find("input[type=submit]").attr("name");
          var submitval = $(this).parents("tr").find("input[type=submit]").val();
          var dataString = $(this).serialize() + "&amp;"+ submitname + "="+ submitval;
          console.log("dataString: " + dataString);
          //submit form
          $.ajax({
              type: "POST",
              url: siteurl,
              data: dataString,
              success: function(){
                  $.ajax({
                      url: siteurl,
                      type:"GET",
                      success: function(portes){
                          //reload page
                          var reloadPortes = $(portes).find("div.tabelaportes table").html();
                          $("div.tabelaportes table").hide().html(reloadPortes).fadeIn("fast");
                          //reload form to add more
                          submitPortes();
                      }
                  });
              }
          });
          return false;
      });
  }
  submitPortes();
  &lt;/script&gt;
  </code></pre>
  
  <p>So, in this case all the forms are in a table. Each row has its own form to remove a row and in the last row, you add rows to the table.
  The function submits the forms and reloads the table. 
  When removing a row, the function works every time, but when adding a row, it only works the first time. What can I do to make it work every time?
  Is it even possible to have one function for all forms?</p>