All,

Again as a newbie to Javascript, I am trying to automate a speed test that will send the results of the test to a php script. I have fumbled around with this, and believe I am making progress. Below is my script which is giving me the error: "Uncaught ReferenceError: testResult is not defined" on line 70. Line 70 reads: "var the_data = 'onTestCompleted='+testResult.download;" Please remember that I am new to this. I would appreciate steps to help me learn how to fix this, and why this isn't working to begin with.

Full code below:

Code:
<html>
<head>
 	<script src="http://speedof.me/api/api.js" type="text/javascript">
	
	// create the XMLHttpRequest object, according browser
	var xmlHttp = new XMLHttpRequest();
function get_XmlHttp() {
  // create the variable that will contain the instance of the XMLHttpRequest object (initially with null value)
  var xmlHttp = null;

  if(window.XMLHttpRequest) {		// for Forefox, IE7+, Opera, Safari, ...
    xmlHttp = new XMLHttpRequest();
  }
  else if(window.ActiveXObject) {	// for Internet Explorer 5 or 6
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }

  return xmlHttp;
}

    </script>
</head>
<body>
<h2>Rental Xpress Internet Speed Test</h2>


<button id="btnStart" type="button" onClick="btnStartClick()">Start Test</button>
<div id="msg"></div>
<script type="text/javascript">


	SomApi.account = "SOM5326f3c941ee5";   //your API Key here
	SomApi.domainName = "rxserver.no-ip.biz";      //your domain or sub-domain here 
	SomApi.config.sustainTime = 4; 
	SomApi.onTestCompleted = onTestCompleted;
	SomApi.onError = onError;

	var msgDiv = document.getElementById("msg");
	
	function btnStartClick() {
		msgDiv.innerHTML = "<h3>Speed test in progress. Please wait...</h3>";
		SomApi.startTest();
		 
	}
	
	function onTestCompleted(testResult) {
		msgDiv.innerHTML = 
		"<h3>"+
			"Download: "   +testResult.download +"Mbps <br/>"+
			"Upload: "     +testResult.upload   +"Mbps <br/>"+
			"Latency: "    +testResult.latency  +"ms <br/>"+
			"Jitter: "     +testResult.jitter   +"ms <br/>"+
			"Test Server: "+testResult.testServer +"<br/>"+
			"IP: "         +testResult.ip_address +"<br/>"+
			"Hostname: "   +testResult.hostname +"<br/>"+
		"</h3>";
	}
	
	function onError(error) {
		msgDiv.innerHTML = "Error "+ error.code + ": "+error.message;
	}
	



// sends data to a php file, via POST, and displays the received answer
function ajaxrequest(php_file, tagID) {
 
  // create pairs index=value with data that must be sent to server
  var  the_data = 'onTestCompleted='+testResult.download;

  request.open("POST", php_file, true);			// set the request

  // adds  a header to tell the PHP script to recognize the data as is sent via POST
  request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  request.send(the_data);		// calls the send() method with datas as parameter

  // Check request status
  // If the response is received completely, will be transferred to the HTML tag with tagID
  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      document.getElementById(tagID).innerHTML = request.responseText;
    }
  }
}

(function(){ setTimeout(btnStartClick, 1500); })();
(function(){ setTimeout(ajaxrequest, 100000); })();
</script>
</body>
</html>