I'm new to web dvlp.. and I needed to make use of some ajax, so I searched around and found some youtube vid explaining it and I kinda got mine to work and this guy did it this way...

Code:
	function SendVotes(FormName) {
	    //alert(FormName);
	    var str = '';
	    var elem = document.getElementById("frm" + FormName).elements;
	    //alert(elem.length);
	    for (var i = 0; i < elem.length; i++) {
	        if (elem[i].type == "radio" || elem[i].type == "checkbox") {
	            if (elem[i].checked == 1) {

	                str += elem[i].value + "|";

	            }
	        }
	    }
	    new Ajax.Request("AddVotes.php", {
	        method: 'post',
	        postBody: 'VotesData=' + str,
	        onFailure: showResponseBad,
			onSuccess: showResponse
	    });
	    document.getElementById(FormName).disabled = true;
	    //$("#td1").css('background', '#F2BCBD');

	}
now that I need to make another.. for the life of me I cant get it to work.. so I searched for more examples and now I dont see that most examples use
this kinda code.. its all using the XMLHttpRequest (below), so it that the better way ? should I stop even trying to do the above ? I think the above
would work to post data to that php page but I had issues getting responses back.. I just want to make sure I start learning the correct or
better way... opinions ?

Code:
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
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("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}