<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var xmlHttpRequest = null;
var url = "http://localhost/miao/second.php";
function ajaxRequest()
{
if(window.ActiveXObject) // IE浏览器
{
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest) // 除IE以外的其他浏览器
{
xmlHttpRequest = new XMLHttpRequest();
}
if(null != xmlHttpRequest)
{
var v1 = document.getElementById("value1").value;
var v2 = document.getElementById("value2").value;
xmlHttpRequest.onreadystatechange = ajaxCallBack;
xmlHttpRequest.open("GET", url + "?v1=" + v1 + "&v2=" + v2, true);
xmlHttpRequest.send();
}
}
function ajaxCallBack()
{
if(xmlHttpRequest.readyState == 4)
{
if(xmlHttpRequest.status == 200)
{
var content = xmlHttpRequest.responseText;
document.getElementById("div1").innerHTML = content;
}
}
}
</script>
</head>
<body>
<input type="button" value="get content from serve" onclick="ajaxRequest()"/><br>
<input type="text" id="value1"/><br>
<input type="text" id="value2"/>
<div id="div1"></div>
</body>
</html>