title: Use Ajax Success Handler to return JSON object
body: <p>I am using an Ajax command to query data from a local server and I need to return a JSON object via the success handler.</p>
  
  <p>My Ajax command looks like this:</p>
  
  <pre><code>var json = $.ajax({
      url: 'http://localhost:9200/wcs/routes/_search',
      type: 'POST',
      data: JSON.stringify({
          "query": {
              "match_all": {}
          }
      }),
      dataType: 'json',
      async: false
  });
  </code></pre>
  
  <p>I'd like to return the JSON document in the variable that I already have assigned: <code>json</code></p>
  
  <p>Could I do something like this in the command? (I know this isn't correct code):</p>
  
  <pre><code>success: return(json);
  });
  </code></pre>