<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AJAX</title>
<script language="javascript" type="text/javascript">
if ( typeof XMLHttpRequest != "undefined" )
{
var Ajax = new XMLHttpRequest();
}
else if ( window.ActiveXObject )
{
var aVersions = ["MSXML2.XMLHTTP.5.0","MSXML.XMLHTTP.4.0","MSXML.XMLHTTP.3.0","MSXML.XMLHTTP","Microsoft.XMLHTTP"];
for ( var i = 0 ; i < aVersions.length; i++ )
{
try {
var Ajax = new ActiveXObject(aVersions) ;
} catch (oError) { }
}
}
if ( !Ajax )
{
alert("cannot install ajax");
}
function getdata(dsource,did,d1,d2)
{
var obj = document.getElementById(did);
Ajax.open('POST',dsource,null);
Ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
Ajax.onreadystatechange = function ()
{
if(Ajax.readyState==4)
{
if (Ajax.status==200)
{
obj.innerHTML = Ajax.responseText;
}
}
}
Ajax.send("d1=" + d1 + "&d2=" + d2);
}
</script>
</head>
<body>
<form>
<input type="button" value="start..." onclick="getdata('data.php','myDIV','text1','text2')" />
</form>
<div id="myDIV">
</div>
</body>
</html>