title: Posting plain text on php using JavaScript
body: <p>I need to use "POST" consisting of value and a variable structure using JavaScript. The plain text should be sent to a PHP page where it will be displayed. How should I get about this?</p>
  
  <p>From what I understand according to my requirement. It needs to be something like a FROM submission, but run only using JavaScript.</p>
  
  <pre><code>document.body.innerHTML += '&lt;form id="content" action="http://10.10.10.10/index.php" method="post"&gt;&lt;input type="hidden" name="info" value="'+plainText+'"&gt;&lt;/form&gt;';
  document.getElementById("content").submit();
  </code></pre>
  
  <p>I tried this code as well.Do you have an Idea on how to display the text sent here on a PHP page? </p>
  
  <pre><code>var request = new XMLHttpRequest();
  request.open("POST", "10.10.10.10/index.php", true); 
  request.onreadystatechange = function () { 
      if(request.readyState === 4){ 
          if(request.status === 200 || request.status == 0){    
              request.setRequestHeader("Content-type","text/plain;charset=UTF-8");
              request.setRequestHeader("Content-length", plainText.length); 
              request.send(plainText); 
          }
      }
  }
  request.send(null);
  </code></pre>