js_ajax

<!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>

posted on 2015-08-11 16:44  奋斗的luy  阅读(121)  评论(0编辑  收藏  举报

导航