title: $.ajax wait for completion without hanging the UI
body: <p>Let's say for example, I have the following javascript function that returns a boolean:</p>
  
  <pre><code>function CallWebServiceToUpdateSessionUser(target, user)
  {
      var dataText = { "jsonUser": JSON.stringify(user) };
  
      $.ajax({
          type: "POST",
          url: target,
          data: JSON.stringify(dataText),
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (response)
          {
              return true;
          },
          failure: function (msg)
          {
              return false;
          }
      });
  }
  </code></pre>
  
  <p>and the target function on the server that is being called could take up to... 15 seconds to respond.</p>
  
  <p>How do I guarantee that this function <strong>will not exit</strong> until after the server call has been completed? Or, how can I guarantee that who ever is calling this function will get a true/false and not an undefined?</p>
  
  <p><em>NOTE:</em>
  I've seen people use async: false but that hangs the UI which I do not want.</p>