AJAX PHP/Javascript and Form Data Issue

software development


I am trying to get a php file to check some data from a form. Right now I just testing if I can send a php file data and it can parrot it back.

My guess is that the problem is with the xmlhttp.open to send part but I am fairly new to AJAX and PHP. The javascript does get the data from the form I have checked that part. When I click on the button nothing happens.

var xmlhttp = new getXMLObject();	

function getXMLObject(){
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest(); //Mozilla, Safari ...
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //IE 6

function ajaxFunction(form) {
	var url = "parrotBack.php";
	var name=form.name.value;
	var data = "name="+name;
	if(xmlhttp) { 
    	xmlhttp.onreadystatechange  = handleServerResponse;
		//xmlhttp.setRequestHeader("Content-length", data.length);
		//xmlhttp.setRequestHeader("Connection", "close");


function handleServerResponse() {
   if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      document.getElementById("result").innerHTML=xmlhttp.responseText;      }
     else {
        txt = "Error during AJAX call. Please try again";

The PHP code

$name = $_POST['name']; 
echo $name;

Here is the HTML section too

<form id="frmMail" name="frmMail" action="">
    	<tr><td>Name: </td>
        <td><input name="name" type="text" size="30" /></td>
	<td colspan="2"><input name="" type="button" value="Send Feedback" onclick="ajaxFunction(document.frmMail)"/></td>
	<div id="result">&nbsp;</div>