标签:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript">
function oAjax(){ //创建ajax对象
var oAjax=null;
if(window.ActiveXObject){
oAjax=new ActiveXObject(‘Microsoft.XMLHTTP‘);
}else if(window.XMLHttpRequest{
oAjax=new XMLHttpRequest();
}
oAjax.open(‘GET‘,‘test.php‘,true); //连接服务器
oAjax.send(null); //发送请求
oAjax.onreadystatechange=function(){ //接收返回值
if(oAjax.readyState==4){
if(oAjax.status==200){
document.getElementById(‘text‘).innerHTML=oAjax.responseText;
}
}
}
}
</script>
</head>
<body>
<input type="button" value="提交" onclick=‘oAjax();‘>
<div id=‘text‘></div>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/luyingying/p/4721459.html