title: Using Jquery to display a modal "please wait" dialog box message
body: <p>Is it possible to block a page when a user clicks on a link and only enable it once the response has come back from the server. 
  I had a problem recently where a link was clicked on a page several times resulting in two simultaneous changes. </p>
  
  <p>The problem was that the page was allowing multiple submit. I have already resolved this on the server side using Struts saveToken() and isValidToken() to prevent this to happen again. This will ensure that if multiple submits are recieved the second one is not processed. </p>
  
  <p>Now the problem i am having is if the user clicks on the submit link twice, the first request is valid but the second is not. The user is redirected to an error page not realising that the first request did go through. </p>
  
  <p>I think the solution is to block/disable the link when it is clicked. I know you can use javascript to disable the link but i would like to use one of the AJAXy modal dialog boxes that i've seen on several sites. Basicly when you click on the link, a pop dialog shows up with a message "Please wait..". The background is faded out and the user cannot do anything until the response has come back from the server. Most of the examples that i see seem to be Ajax based. My page does not use Ajax. </p>
  
  <p>What is the easiest way to achieve this modal dialog box? I have been looking around and there are several plugins available for JQuery but given that i am new to it i dont quite understand it. Can someone show me an example of how to do this using Jquery? </p>
  
  <p>Thanks</p>
  
  <h2>EDIT</h2>
  
  <p>Take this for example, </p>
  
  <pre><code>            //CONTROLLING EVENTS IN jQuery
              $(document).ready(function(){
  
                  //LOADING POPUP
                  //Click the button event!
                  $("#button").click(function(){
                      //centering with css
                      centerPopup();
                      //load popup
                      loadPopup();
                  });
  
                  //CLOSING POPUP
                  //Click the x event!
                  $("#popupContactClose").click(function(){
                      disablePopup();
                  });
                  //Click out event!
                  $("#backgroundPopup").click(function(){
                      disablePopup();
                  });
                  //Press Escape event!
                  $(document).keypress(function(e){
                      if(e.keyCode==27 &amp;&amp; popupStatus==1){
                          disablePopup();
                      }
                  });
  
              });
  </code></pre>
  
  <p>I would like these events to be triggered when i click on a link. The link itself points to another javascript function. i.e. </p>
  
  <pre><code>&lt;a href="javascript:submitform();"&gt;confirm&lt;/a&gt;
  </code></pre>
  
  <p>How can i call the jquery bits inside of the submitform() javascript function? Preferabley after the submitform() has completed. </p>