problems fetching data response

I am trying to work on an assignment to fetch a data response. But, when I bring it up in a browser and click on it, instead of bringing up the right message it brings up all of them and I cant figure out why.

<!--Startwith index.html-->
<script type="text/javascript">
function fetchData(url, dataToSend, objectID){
	var pageRequest = false;
	if (window.XMLHttpRequest) pageRequest = new XMLHttpRequest();
	else if (window.ActiveXObject) pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
	else return false;
	pageRequest.onreadystatechange = function() {
		var object = document.getElementById(objectID);
		object.innerHTML = pageRequest.responseText;
	if (dataToSend) {
		var sendData = 'sendData=' + dataToSend;'POST', url, true);
	pageRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	else {'GET', url, true);
** Technique 2: Sending Data  **
<body background="lilo12b.jpg">
<h1>Which Lilo & Stitch character are you?</h1>
<div id="control"
<div id="control"
<div id="control"
<div id="control"
<div id="message">&nbsp;</div>
<a href="index.html">Home</a>
{ $searchString = $_POST["sendData"];
	if ($searchString == 1) $dataResults =
		sprintf("<h1>Hello Lilo!</h1>");
	else if ($searchString == 2) $dataResults =
		sprintf("<h1>Hello Stitch!</h1>");
	else if ($searchString == 3) $dataResults =
		sprintf("<h1>Hello Jumba!</h1>");
	else if ($searchString == 4) $dataResults =
		sprintf("<h1>Hello Pleakley!</h1>");
	else $dataResults =
		sprintf("<h1>Aloha, cousin!  Welcome to Hawaii!</h1>");
echo $dataResults;

What have you done to try and debug the problem? Where do you think the problem might be? Is the problem with the PHP or the JavaScript?

I think more info is needed.

Sponsor our Newsletter | Privacy Policy | Terms of Service