title: Returning string in Ajax success function
body: <p>I'm trying to return a string back after my Ajax is executed, however; I'm getting the word undefined instead of the string. I understand that the code is being executed asynchronously, but I don't understand how I can make a solution for my problem. </p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>function aggregator(field){
      var query = '{"aggs": { "group_by_date": { "terms": { "field": "' + field + '" } } } }';
  
       $.ajax({
          url: 'index.php',
          type: 'post',
          data: {
              qSet: query
          },
          success: function(message){
              return message;
          }
      });
  
  }
  
     var results = aggregator("transactionDate");
     document.getElementById("results").innerHTML = results;
  </code></pre>
  
  <p>How do I make it so that my element in HTML has the returned value?</p>