title: To call an asynchronous function synchronously in javascript
body: <pre><code> we are trying to change some calls in the application from sync to async then i read the post
  </code></pre>
  
  <p>"<a href="https://stackoverflow.com/questions/9121902/call-an-asynchronous-javascript-function-synchronously">Call An Asynchronous Javascript Function Synchronously</a>"
  so when i call the callThis() I am getting the output as:
     "Success"
     "failure"
  but I need the output as 
     "Success"
     "KATE success"</p>
  
  <p>Can you guys suggest me a solution for this, not the callback or timeout but still an efficient technique when changed from sync to async<br></p>
  
  <pre><code>function callThis()
  {
      if(kate())
      {
        console.log("KATE success")
      }
   else
    {
     console.log("failure")
    }
  }
  function kate()
  {
    $.ajax({
          url: "www.google.com" (http://www.google.com),
          type: 'get',
          async: true,
          timeout: 10000,
          success: function (data) {
              console.log("Success");
          },
          error: function () {
              console.log("FAIL!!!");
          }
      });
  }
  </code></pre>