title: How to detect form submit timeout and re-submit?
body: <p>We're using an unreliable endpoint to submit a form, which occasionally times out.</p>
  
  <pre><code>window.onload = function(){
    document.forms['form-to-third-party-endpoint'].submit()
  }
  </code></pre>
  
  <p>What's the best way to detect the timeout and try re-submitting the form? Perhaps try it 5 times before giving up.</p>
  
  <p>This is a 3rd-party integration -- the form loads up in an iframe and automatically submits to get the HTML content.</p>
  
  <p>Note: Yes, a better solution would be to fix the timeout. But we need to take out system live and can't wait for the 3rd party.</p>