title: synchronous ajax call - show div before call
body: <p>I need to make a div that covers my entire screen be displayed before an sync ajax call.</p>
  
  <p>But it seems that absolutely nothing I try to do causes the DOM to be modified to show this div before the ajax call. The screen gets "frozen" and the div is showed only after the ajax call is executed.</p>
  
  <p>I have already tried "thousands" of approaches but nothing seems to make ajax run only after the DOM is modified (shows the div).</p>
  
  <p>HTML</p>
  
  <pre><code>[...]
  &lt;body&gt;
      &lt;div id="loadingDiv" style="display: none; width: 100%; height: 100%; background-color: #004000; position: absolute; z-index:10000;"&gt;&lt;/div&gt;
  [...]
  </code></pre>
  
  <p>javascript</p>
  
  <pre><code>[...]
  $("#loadingDiv").css("display", "block");
  var ajaxOp;
  $.ajax({
      type: someType,
      url: someUrl,
      data: someData,
      dataType: someDataType,
      async: false,
      success: function (someArg) {
          ajaxOp = someArg;
      },
      error: function (someArg0, someArg1, someArg2) {
          // do something
      }
  });
  return ajaxOp;
  [...]
  </code></pre>
  
  <p><strong>NOTE I:</strong> I'm using JQuery.<br>
  <strong>NOTE II:</strong> "ajaxOp" can not be "undefined".</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong> In the hope that it helps the understanding and at the request of @Felipe Dutra Ferreira I put some more explanations about the issue in the update below...</p>
  
  <p>THE REAL CASE: I have an application with several legacy codes that consume a libray js with a function that, in turn, makes ajax calls (let's call it "certainfunction"). We are trying to update this application so that it displays a "loading screen" during ajax calls (not just "lock" the UI during these calls). So the simplest way to handle this problem is display the "loading screen" just after the calls to "certainfunction" and before it runs the ajax calls. Note also that "certainfunction" returns the output from the ajax call and this output will be "undefined" once this call is not executed synchronously, that is, the code can only continue after this ajax call has an output.</p>