title: Debounce clicks when submitting a web form
body: <p>A poorly-written back-end system we interface with is having trouble with handling the load we're producing. While they fix their load problems, we're trying to reduce any additional load we're generating, one of which is that the back-end system continues to try and service a form submission even if another submission has come from the same user.</p>
  
  <p>One thing we've noticed is users double-clicking the form submission button.  I need to de-bounce these clicks, and prevent a second form submission.<br>
  My approach (using Prototype) places an <code>onSubmit</code> on the form that calls the following function which hides the form submission button and displays a "loading..." <code>div</code>.</p>
  
  <pre><code>function disableSubmit(id1, id2) {
      $(id1).style.display = 'none';
      $(id2).style.display = 'inline';
  }
  </code></pre>
  
  <p>The problem I've found with this approach is that if I use an animated gif in the "loading..." <code>div</code>, it loads fine but doesn't animate while the form is submitting.</p>
  
  <p>Is there a better way to do this de-bouncing and continue to show animation on the page while waiting for the form result to (finally) load?
  ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>