title: jQuery stop ajax running asynchrously
body: <p>Is there a way to prevent ajax running async? </p>
  
  <p>jQuery:</p>
  
  <pre><code>var returnValue = false;
          var appCount = 0;
  
          $.ajax({
              type: "GET",
              url: "getBookedAppointmentCountByDoctorAndDate.php",
              data: dataString,
              success: function (response){
                  appCount = response;
                  //alert(appCount);
                  if(appCount &gt;= 6){
  
                      returnValue = true;
                  }
              }
          });
          return returnValue;
  </code></pre>
  
  <p>I have an if statement in my code that checks the return value of this function. Because Ajax runs async, the if statement is continuing before the return value is set. Any ideas or suggestions of other methods to use to return php value?</p>
  
  <pre><code>if (blah($(this)) === true) {
                      alert("blah");
                  } else { ...
  </code></pre>