title: Finish function executing before proceeding
body: <p>I have a form that is validated upon submission, inside the form submit a function is called, the submit continues and doesn't wait for the function to finish. How do I fix this?</p>
  
  <pre><code>var clientaddress=false;
  
  function checkaddress(callback){
      var geocoder = new google.maps.Geocoder();
      geocoder.geocode({'address': address}, function(results, status) {
          if (status != google.maps.GeocoderStatus.OK) {
              clientaddress=false;
               callback(false);
          }
         else if (status == google.maps.GeocoderStatus.OK) {
              clientaddress=true;
              callback(false);
         }
      }
  
   jQuery(document).ready(function(){
       jQuery("#submitOrder").submit(function(){
          checkaddress(function(result) {
  
                      if (!result) { 
                          jAlert("Please enter a valid address!");
                          jQuery("#address").focus();
                          isValidation = 0; 
  
                      }
                  });
  
         //other validation code that gets executed without waiting for checkaddress()
         //submit page
       })
  </code></pre>
  
  <p>I tried to make one function that calls both the address checker and a validation function, but still they do not wait for each other.</p>
  
  <p>How can I solve this problem?</p>