title: Post variables not set when submitting a form with JS
body: <p>I have a form I submit with javascript as soon as the user clicks a label. There is a weird behavior where the datas are not posted. But if I submit the form with a delay (even with a delay of 0) it works.</p>
  
  <p>Here is the html:</p>
  
  <pre><code>&lt;form action="/other-page" method="post"&gt;
      &lt;input id="val-1" type="checkbox" name="filter[]" value="1"&gt;
      &lt;label for="val-1"&gt;Value 1&lt;/label&gt;
  
      &lt;input id="val-2" type="checkbox" name="filter[]" value="2"&gt;
      &lt;label for="val-2"&gt;Value 2&lt;/label&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The script:</p>
  
  <pre><code>&lt;script&gt;
      $('label').click(function() {
          var form = $(this).closest('form')
  
          // if I use the following line the values won't be set
          form.submit()
  
          // If I use a `setTimeout` it works, even with a delay of 0
          setTimeout(function() {
               form.submit()
          }, 0)
      })
  &lt;/script&gt;
  </code></pre>
  
  <p>It's not a big issue as I can make this work with the <code>setTimeout</code> but writing this with a delay of 0 is really ugly. I thought about a browser bug but I tested with Chrome and Firefox and I have the same result.</p>
  
  <p>Any idea about what is happening?</p>