title: How to access data from a function that return an ajax get json response?
body: <p>I have a function that return json data using ajax:</p>
  
  <pre><code>function validateTagRequest(fileName) {
      $.ajax({
          type: "GET",
          dataType: "json",
          url: "/tags/find-tag/"+fileName.tag,
          success: function(data){ 
              console.log(data);
              return data;
          }
      });
  };
  </code></pre>
  
  <p><code>console.log(data)</code> show exactly what I need.</p>
  
  <p>But then I call the function:</p>
  
  <pre><code>var response = validateTagRequest(fileName);
  useResponse(response); // this don't work, response = undefined
  console.log(response);
  </code></pre>
  
  <p><code>console.log(response)</code> return undefined</p>
  
  <p>How can I handle the asynchronous of js to execute this code in order?</p>