title: Javascript alternative of jQuery.ajax() - facing errors
body: <p>This is the <code>JS Object</code> </p>
  
  <pre><code>var datas = {
      name: "xyz",
      age:21,
  }
  
  var datas2 = JSON.stringify(datas);
  </code></pre>
  
  <p>The below AJAx Request is passing datas correctly</p>
  
  <pre><code> $(function(){
          $.ajax({
              url:'two.php',
              type:'POST',
              dataType:'html',
              data:{data:datas2}
          });
      });
  </code></pre>
  
  <p><strong>Response in the developer tools:</strong></p>
  
  <pre><code>Array
  (
      [data] =&gt; {"name":"xyz","age":21}
  )
  </code></pre>
  
  <p>Now tried with <strong>Javascript AJAX Reuest</strong></p>
  
  <pre><code>var xmlhttp;
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
      {
  
      }
    }
  xmlhttp.open("POST","two.php",true);
  xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  // xmlhttp.setRequestHeader("Content-type","application/json");
  xmlhttp.send(datas2);
  </code></pre>
  
  <p><strong>Response in the developer tools:</strong></p>
  
  <pre><code>Array
  (
      [{"name":"xyz","age":21}] =&gt; 
  )
  </code></pre>
  
  <p>Where am I going wrong?</p>