title: Synchronous form submits when posting to iframe
body: <p>I have a form which POSTs data to a hidden <code>&lt;iframe&gt;</code> to prevent the page from changing. However I would like the Save button to perform two consecutive <code>submit()</code>s, one after the other.</p>
  
  <pre><code>&lt;form name="updatedocform" id="updatedocform" method="post" action="http://foo.bar" enctype="multipart/form-data" target="hiddenframe"&gt;
      ...
      &lt;input type="submit" onclick="save(); return false;" value="Save" /&gt;
  &lt;/form&gt;
  &lt;iframe name="hiddenframe" id="hiddenframe"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>function save() {
      document.updatedocform.submit();
      // change some form values here
      // alert("paused"); // if this alert is here, everything works fine
      document.updatedocform.submit();
  }
  </code></pre>
  
  <p>However the second <code>submit()</code> is being called before the first one is finished loading. Is there a way to make the second submit wait for the first one to finish?</p>
  
  <p>I could use a <code>setTimeout()</code> but I'd like a cleaner solution that doesn't depend on the speed of the network.</p>