title: How to wait for JQUERY AJAX response before choosing condition
body: <pre><code>$("#submit").click(function () {
      var boolError = false;
  
      CheckForm("#email");
      CheckPhone("#phone");
  
      if (boolError == true) {
          console.log('error');
      } else {
          console.log('here');
          // $("#form").submit();
      }
  });
  </code></pre>
  
  <p>Problem is that it always returns <code>console.log('here');</code></p>
  
  <p>Is there a way to wait for CheckForm and CheckPhone. AJAX call from CheckForm function:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "/webservice/user.asmx/CheckForm",
      data: "{'type':'" + var_type + "', 'value':'" + var_value + "'}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      error: function (XMLHttpRequest, textStatus, errorThrown) { },
      success: function (data) {
          var obj = data.d;
      }
  });
  </code></pre>