title: Ajax request with JavaScript responds with 302 (Found)
body: <p>I am trying to send data by Ajax with the Post method, but the answer gives me <code>302 (Found)</code> and I do not know what it can be. This is my code:</p>
  
  <pre><code>function sendData(){
  
    if (window.XMLHttpRequest) { 
      xmlhttp = new XMLHttpRequest(); 
    } else { 
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    }
  
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
        console.log("Response" + xmlhttp.responseText);
      }
    }
  
    xmlhttp.open("POST", "request.php", true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.send("name="+document.getElementById('username').value);
  
  }
  </code></pre>
  
  <p>and my .php file only print a message</p>
  
  <pre><code>&lt;?php echo 'hello : ' . $_POST["name"] ?&gt;
  </code></pre>