I'm sending JavaScript values via POST method using AJAX. Everything works fine except that I'm unable to send strings with & (ampersands). I tried encodeURIcomponent but nothing seems to work. Everything after the ampersand gets lost.
This is my code:
AJAX call
function chpr(gffo){
  var fd=gffo;
  var vl=document.getElementById(message).value;
  vl = encodeURIComponent(vl);
  if((vl)!=""){
    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 && xmlhttp.status==200)
      {
        document.getElementById("msg").innerHTML=xmlhttp.responseText;
      }
    }
    xmlhttp.open("POST","example.php",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send("q="+fd+"&w="+vl);
  }
}
On the PHP side I'm fetching it as:
$w = $_POST['w'];
So for example if I want to send Me & You,
on the PHP side it fetches just Me.
 
     
     
     
     
    