Hi everybody,

I'm having a bit of trouble getting this Ajax post request to work properly.
The whole js file contains my GET function, which works fine, but I can't seem to get the post one working. It hangs on the line I've highlighted when I call it:

Code:
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 	try {
 		 xmlhttp = new XMLHttpRequest();
 	} catch (e) {
 		 xmlhttp=false;
 	}
}

if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}


var please_wait = "Loading...";

function open_url(oldurl, targetId) {
  if(!xmlhttp)return false;
    var e=document.getElementById(targetId);if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;
    urlsize = oldurl.length-3;
    if (oldurl.indexOf('php') == urlsize)
		{
    url = oldurl + '?rannum=' + Math.floor(Math.random()*100001);
    } else {
    url = oldurl + '&rannum=' + Math.floor(Math.random()*100001);
    }
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() { response(url, e); }
    try{
      xmlhttp.send(null);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("request failed"));
  }
}

function post_reply(url, targetId) {
  if(!xmlhttp)return false;
    var e=document.getElementById(targetId);if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;
    urlsize = oldurl.length-3;
    //params = "pid=2&title=ThisIsIt";
    xmlhttp.open("POST", url, true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", params.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.onreadystatechange = function() { response(url, e); }
    try{
      xmlhttp.send(params);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("request failed"));
  }
}

function response(url, e) {
  if(xmlhttp.readyState != 4)return;
    var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "<h2><font color=\"red\">Error: \"" + xmlhttp.status+" "+xmlhttp.statusText + "\"</font></h2><h3>Please let a member of admin know that the link/function you used doesn't work.</h3><h3><a href=\"javascript:void(0);\" onclick=\"open_url('pages/pages.php','main');\">Homepage</a></h3>";
    var d=document.createElement("div");
    d.innerHTML=tmp;
    setTimeout(function(){
      while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
      e.appendChild(d);
    },10)
}
As you can see from the code, when I call something like:
Code:
open_url('pages/home.php','main');
it works fine, but the post_reply() function just hangs.

I'm getting quite frustrated with this. Can anyone give it an eyeball check to see if I've done something wrong or missed something please?

Many thanks
David