I am new to AJAX. Could someone please help me with this problem.. its kind of urgent for me to get this working.

I have a form which when submitted should create an XMLHttpRequest to send the form values to a PHP script. Below is my code for the request.
On IE I get an error saying 'Type Mismatch' at xmlHttp.onreadystatechange=stateChanged(id);
As you can see in my function stateChanged(id) I have an else statement to check xmlHttp.readyState. This shows as '0', so the request is not getting initialized. What do I need to change?
Thanks!

Code:
var xmlHttp

function save(id)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var name = $("desc"+id).value;
var capacity = $("capacity"+id).value;
var equipid = $("equip"+id).value;

var params = 'desc='+name+'&capacity='+capacity+'&id='+equipid;

xmlHttp.onreadystatechange=stateChanged(id);
xmlHttp.open("POST","trialsubmit.php",true);
xmlHttp.send(params);
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function stateChanged(id) 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
$("name"+id).innerHTML=xmlHttp.responseText;
}
else
 { 
  $("name"+id).innerHTML=xmlHttp.readyState;
 }
}