Thursday, July 14, 2011

And ajax test page

While building the radiation map prototype i put together a ajax data grabber here it is

<html>
<head>
<script type="text/javascript">
function loadData(str)
{
var xmlhttp;    
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","/safecast/data.php?lat=1&long=2",true);
xmlhttp.send();
}
</script>
</head>
<body>

<div id="txtHint">
<button onclick="loadData('')">Get Data</button>
</div>

</body>
</html>

No comments:

Post a Comment