title: Node.js server that accepts POST requests
body: <p>I'm trying to allow javascript to communicate with a Node.js server. </p>
  
  <p><strong>POST request (web browser)</strong></p>
  
  <pre><code>var http = new XMLHttpRequest();
  var params = "text=stuff";
  http.open("POST", "http://someurl.net:8080", true);
  
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");
  
  alert(http.onreadystatechange);
  http.onreadystatechange = function() {
    if (http.readyState == 4 &amp;&amp; http.status == 200) {
      alert(http.responseText);
    }
  }
  
  http.send(params);
  </code></pre>
  
  <p>Right now the Node.js server code looks like this. Before it was used for GET requests. I'm not sure how to make it work with POST requests.</p>
  
  <p><strong>Server (Node.js)</strong></p>
  
  <pre><code>var server = http.createServer(function (request, response) {
    var queryData = url.parse(request.url, true).query;
  
    if (queryData.text) {
      convert('engfemale1', queryData.text, response);
      response.writeHead(200, {
        'Content-Type': 'audio/mp3', 
        'Content-Disposition': 'attachment; filename="tts.mp3"'
      });
    } 
    else {
      response.end('No text to convert.');
    }
  }).listen(8080);
  </code></pre>
  
  <p>Thanks in advance for your help.</p>