title: Disable Button Call Server then Re-enable Button
body: <p>I've seen many similar questions to mine, but have spent a few hours browsing and can't find the answer to my situation.</p>
  
  <p>I have a Go based web-server.  I have an HTML template page that lets me update the hardware clock and system clock on a 'nix system with the current browser time:</p>
  
  <p><a href="https://i.stack.imgur.com/PX2R6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PX2R6.png" alt="enter image description here"></a></p>
  
  <p>The update button is of type submit and calls the Go code which makes some system calls which take a few seconds, and I can't have this server code being called twice whilst it's still processing the first request. </p>
  
  <p>So I want to disable the update button and then re-enable it once the server has responded.</p>
  
  <p>I have jQuery, so I know I can have a function that is called via `onclick' and make these calls:</p>
  
  <pre><code>$("#updateButton").prop("disabled", true);
  $("#updateButton").prop("disabled", false);
  </code></pre>
  
  <p>I have the form being submitted via the button (and not a jQuery call for instance - although I'm all ears) because I want the form to refresh when the server responds.  So I have this:</p>
  
  <pre><code>&lt;form action="/clock" method="POST"&gt;
      ...
  &lt;/form&gt;
  </code></pre>
  
  <p>This is so some values on the page get updated. Such as the status message at the top and the values in the various fields (updated to the values actually set).</p>
  
  <p>The first problem I have is that if I call a JS function on the button click, and it disables the button as per above, then my server code doesn't get called!  I have no idea why - could this be stopping the post request somehow?</p>
  
  <pre><code>&lt;script&gt;
  function getTime() {
      // Disable update button while waiting for response
      $("#updateButton").prop("disabled", true); // Stops post request???
  
      // How to re-enable update button?
  
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And secondly, how do I re-enable the button?  I don't know how to tell when the server has responded.</p>