title: Return true/false on submit button click, based on ajax response
body: <p>Based on some JSON I recieve from an ajax request, I wish to either allow or deny a submit button press (return true/false). </p>
  
  <p>I've attempted to implement a promise, however, I can still see 'product unavailable' is called before I recieve my ajax response.</p>
  
  <p>Is the issue down to it being a form/submit button? Or is this still possible?</p>
  
  <pre><code>var oAH = {
  
      ValidateSubmit : function(self){
  
          // send request to handler
          $.ajax({
              type: "POST",
              url: "",
              data: aData,
              cache: false})
          .done(function(data) {
  
              var oJSON = JSON.parse(data);
              if(oJSON.Status === 1){
                  // return true to allow form to submit
                  return true;
              }else{
                  console.log('product unavailable (error message)');
                  return false;
              }
          })
  
  
      }
  }
  
  
  // click handler
  $('#submitButton').on('click', function(){
      return oAH.ValidateSubmit(this);
  }
  </code></pre>