I'm working on an app that grabs some html off of a page and using Ajax puts the html into a database. The problem I'm having is that when a url in the html contains an ampersand the html is cutoff at that point, like:

<a title="mysite" href="mysite.com.php?id=1&?day=2">hello</a>

becomes

<a title="mysite" href="mysite.com.php?id=1"></a>

Is there a good way to deal with this? Javascript's escape seems to be one workaround but then I need to unescape using php before the code gets put into the db.

Also, the amount of html I'm sticking into a db is fairly large(about 2000 lines) and it's actual structure changes outside of my control.

Here's the javascript Ajax code:
Code:
function createXMLHttpRequest(){
  try{ return new ActiveXObject("Msxml2.XMLHTTP");} catch(e){}
  try{ return new ActiveXObject("Microsoft.XMLHTTP");} catch(e){}
  try{ return new XMLHttpRequest();} catch(e){}
  alert("ajax not supported");
  return null;
}


function sendBody(){
  var bod = document.getElementsByTagName("body")[0];
  var innerBod = bod.innerHTML;
  var params = "bod=" + innerBod;
  var xhr=createXMLHttpRequest();
  xhr.onreadystatechange = function(){
    if(xhr.readyState==4){
      if(xhr.status==200){
        bod.innerHTML = xhr.responseText;
      }else{
        alert("error");
      }
    }
  }
  xhr.open("POST", "process.php", true);
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhr.setRequestHeader("Content-length", params.length);
  xhr.setRequestHeader("Connection", "close");
  xhr.send(params);
}
Thanks.