how to show the div on click of button while the processing in side the button click is going on.

how to show the div on click of button while the processing in side the button click is going on.

i want to block the web page so that if i click save button, then while the save button is processing one should not be able to click on any other button and after the process of the click of save button is over then form should be available.
 
Q1) how many ways this could be achieved.
q2) following is the way i am using but it is not showing the div unless the processing of the loop finishes.


  1.  <style>

  2.         #popupblock {
  3.             width: 100%;
  4.             height: 100%;
  5.             position: fixed;
  6.             z-index: 9999;
  7.             top: 0;
  8.              background:url("~/Content/loader.gif") no-repeat center center rgba(0,0,0,0.25)
  9.         }

  10.     </style>

  11.       <div  id="popupblock" style="display:none;">
  12.         
  13.     </div>
  14.     <input id="Button1" type="button" value="button" 

  15. <script type="text/javascript">
  16.         $(document).ready(function () {
  17.           
  18.             $("#Button1").click(function () {
  19.                
  20.                 $('#popupblock').show();



  21.                 let ii = 0;
  22.                 let text = "";
  23.                 while (ii < 19000000) {
  24.                     text += "the number is " + ii;
  25.                     var t = text;
  26.                     ii++;
  27.                 }

  28.                 $('#popupblock').hide();
  29.             });
  30.  
  31.         });
  32.     </script>