<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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。