Simple ajax form not working not displaying updated

Hi there,

i am wanting to develop a ajax application a simple one i found using an ajax div refresh in a project i am currently working on but i have never done such a thing where i change the div of the submited content

here is a copy of my ajax and html code


<script type="text/javascript">
<!-- 
//Browser Support Code
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var age = document.getElementById('per').value;
	var wpm = document.getElementById('email').value;
	var queryString = "?per=" + age + "&email=" + wpm;
	ajaxRequest.open("POST", "testPost.php" + queryString, true);
	ajaxRequest.send(null); 
}
</script>
<body>
<div id="ajaxDiv"><form method="post" action="" name="myForm">
	<input type="text" name="per" id="per" />
    <input type="text" name="email" id="email" />
    <input type="submit" name="set" value="Send Info"onclick='ajaxFunction()' />
</form>
</div>

My problem is why isnt the div ajaxDiv not displaying the content of test.php once the data has been submitted?

can anyone help me with this please in what i am doing wrong so basically i am wanting to get the content of ajaxDiv to be updated with new content once the submit button has been pressed.

But my ajax and html code doesnt want to do this for my php code i have this


print_r($_POST);

Just so i can see what is being sent but i cant see anything and most of the time i get ajax errors or is it somthing wrong in the php code part?

can anyone help me find out as i am keen to learn to use ajax in all of my web applications i develop.

Thanks,William

You may wish to investigate the book called Bulletproof Ajax which also provides online all of the [url=“http://bulletproofajax.com/code/”]code examples and live demos.