How to stop the page loading until do not get a response from ajax?

How to stop the page loading until do not get a response from ajax?

You can do it with the ajax function with the async property set to false.

 $.ajax({
     url: "/acme/confirm_authentication",
     success: function(data) {
         if( data != "confirmed"){
             location.href = "logout";
         }
     },
     async:false
  });