title: Javascript return true or false to callback from another function
body: <p>I’m using jQuery validate plugin that has a callback submitHandler. In that callback if it returns false, it aborts the submit and if it returns true it submits using the post method. </p>
  
  <pre><code>  $("#collection_form").validate({
  
      submitHandler: function(form) {
  
          pre_ajax_submit(function (pre_ajax_return) {
  
              if (pre_ajax_return == 'non_ajax') {
                  //something
              } else {
                  //other
              }
          });
      }
  });
  </code></pre>
  
  <p>So my question is: I have a function in the callback <code>pre_ajax_submit()</code>. How can I have a function return true or false in the main callback. I want to achieve the same result as this:</p>
  
  <pre><code>$("#collection_form").validate({
  
      submitHandler: function(form) {
          return true;
      }
  });
  </code></pre>