title: Unique function for ajax request not working
body: <p>I'd like to create unique function for ajax post request.</p>
  
  <p>This is actual source code:</p>
  
  <pre><code>function doAjax(url, postData) {
  
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 &amp;&amp; xhttp.status == 200) {
          return xhttp.responseText;
      }
    };
    xhttp.open("POST", url, true);
    xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhttp.send(postData);
  
  }
  
  console.log( doAjax('shipment.php', 'fname=test1&amp;lname=test2') );
  </code></pre>
  
  <p>But it's not working, the console shows "undefined".</p>
  
  <p>But, if I change return on alert() - everything is OK.
  So, why return now working ?</p>