title: How can I access data returned from ajax call outside AJAX callback function in my case?
body: <p>I have a function which generate ajax call to server:</p>
  
  <pre><code>function askServer(callback) = {
       $.ajax({
         // ...
         async: true, //I have to use true here
         success: function(response) {
           callback(response); //callback handle server response
         },
  
       });
    };
  </code></pre>
  
  <p>The function to handle server response:</p>
  
  <pre><code>function handleResponse(){
       var dataObject;
       askServer(function(response){
  
           //response is an object {car:{id:2, name:TOYOTA}}
           dataObject=response.car;
       });
      //Now, I would like to access the dataObject outside callback function
      //but if I make it like this, the dataObject value will be null because it is outside the callback
  
  }
  </code></pre>
  
  <p>How can I access <code>dataObject</code> outside callback function as I indicated above? (the <code>dataObject</code> contain server response data)</p>
  
  <p>I have to use <code>async: true</code>, I know I can get rid of the problem if I use <strong>async: false</strong>.</p>