Here's the text for testAjax.html followed by the text for calc.php. Sorry it's so long. My results were obtained using Firefox:
-----------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script>
function getReq()
{
try {
var req = new XMLHttpRequest()
} catch(e1) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP")
} catch(e2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP")
} catch(e3) {
req = false
}
}
}
return req
}
//==============================================
function getValues(id)
{
var elem = document.getElementById(id);
return elem.value;
}
//==============================================
function calc()
{
var req = getReq();
if (!req) {
alert("Oops!");
return false;
}
var param = "";
param += ("lat1d=" + getValues("lat1d") + "&");
param += ("lat1m=" + getValues("lat1m"));
req.open("GET", "[
localhost]; + param, true);
req.onreadystatechange = function()
{
if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseText != null) {
alert("Got response");
info = this.responseText.split(",");
if (!info) { alert("No response text"); return;}
document.getElementById('init').innerHTML = info[0];
document.getElementById('dist').innerHTML = info[1];
}
else alert("No response text");
}
else alert("Ajax error: " + " " + this.readyState + " " + this.status + " " + this.responseText.length);
}
}
req.send();
}
//==================================================
function zero(id)
{
var elem = document.getElementById(id);
elem.value = 0;
}
//====================================================
function clear()
{
zero("lat1d");
zero("lat1m");
}
</script>
</head>
<body>
<font face="Arial">
<h1 align="center">The Great Circle Calculator</h1>
<form action="<script>calc();</script>" method="get">
<font face="Arial">
<table align="center">
<tr>
<td> </td>
<td align="center">DDD</td>
<td align="center">MM.M</td>
</tr>
<tr valign="middle">
<td><font color="#FF0000"><b>Lat 1</b></font></td>
<td><input id="lat1d" name="lat1d" size="5"></td>
<td><input id="lat1m" name="lat1m" size="8"></td>
</tr>
<tr>
<td align="center" colspan="8"><button type="button" onclick="calc();">Calculate</button></td>
</tr>
</table>
<br/><br/>
<table align="center">
<tr>
<td >Initial course</td>
<td id="init" name="init" width="30"> </td>
<td >Distance</td>
<td id="dist" name="dist" width="30"> </td>
</tr>
<tr valign "middle">
<td align="center" colspan="4">
<button type="reset" onclick="clear();">Reset</button>
</td>
</tr>
</table>
</font>
</form>
</font>
</body>
</html>
-------------------------------------------------------------
<?php
$hdl = fopen('c:\\web\\trace.txt', 'a');
fwrite($hdl, "Input rcvd\n");
if (isset($_GET["lat1d"]))
fprintf($hdl, "%d\n", $_GET["lat1d"]);
else
fwrite($hdl, "No post\n");
$lat1 = (int)$_GET["lat1d"] + (float)$_GET["lat1m"] / 60.0;
$lat2 = sprintf("%f", $lat1);
echo "$lat2,60";
fprintf($hdl, "%s\n", ob_get_contents());
fclose($hdl);
flush();
?>