title: Refused to set unsafe header Connection/Content-length
body: <p>I'm working on a website and I have a problem right here. On the page I'm working, the user puts an ip address and the ports he wants to be searched. This is being made with ajax (user side) and php (server side). Ajax sends the ip and port (one by one) to the php file, and he returns the result of the port. The goal is that user sees what's the port is being tested (in a div element) at the moment, and here is where the problem is. He runs/works well, he tests all the ports the user wants to, but during the test period he shows no port, just shows the final port (after all previous ports have been tested) and the result of the ports (if some port had a result) which appears in a distinct div element. This just works perfectly in Firefox, in other browsers happens what I just explained. The Google Chrome console says: Refused to set unsafe header "Content-length" and Refused to set unsafe header "Connection". I've been searching about this problem for days and I found so many things and I tried them, but none of them solved the problem.</p>
  
  <p>Here is my code.</p>
  
  <p><i>jquery.js</i></p>
  
  <pre><code>function HttpRequest(endereco, portainicio)
  {      
      var xmlhttp;
      var params = "endereco="+endereco+"&amp;"+"porta="+portainicio;
  
      if (window.XMLHttpRequest) // IE7+, Firefox, Chrome, Opera, Safari
      {
          xmlhttp = new XMLHttpRequest();
      }
  
      else // IE6, IE5
      {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
  
      xmlhttp.open("POST", "/firewall/ajax", false);
  
      //alert(params);
  
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.setRequestHeader("Content-length", params.length);
      xmlhttp.setRequestHeader("Connection", "close");
  
      xmlhttp.send(params);
      return xmlhttp.responseText;
  }
  
  function ajaxfirewall()
  {
      (...)
  
      var resposta;
  
      $("p.ip").append("&lt;span class='end'&gt; "+endereco+"&lt;/span&gt;");       
  
      for (portainicio; portainicio &lt;= portafinal; portainicio++)
      {   
          resposta = HttpRequest(endereco, portainicio);              
          $("p.porta").append(" &lt;span class='tporta'&gt;"+ resposta+"&lt;/span&gt;&lt;br&gt;");
      }
  
      return false;
  }
  </code></pre>
  
  <p>Another thing it's really strange. Do you see those <code>alert(params);</code> which are commented in the <code>HttpRequest</code> function? If I leave it uncommented it displays the port which is being tested, but it shows the alert and I don't want that.</p>