分享

自己写的最简单的ajax程序

 竹林书屋@ 2011-10-06
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ajax test</title>
<link type='text/css' rel='stylesheet' href='../css/ajax.css' />
</head>
<body>
<div id='root'></div>
<div id='content'></div>
<script type="text/javascript">
var http;
http=new XMLHttpRequest();//had got
function chuli(url){
    http.onreadystatechange=showcnt();
    http.open('GET',url);
    http.send();
}
function showcnt(){
    if(http.readyState===4){
        if(http.status===200){
            document.getElementById('content').innerHTML=http.responseText;
        }
    }
}
document.getElementById('root').onclick=function(){chuli('data.txt');};
</script>
</body>
</html>
firfox核心可以运行
ie下加载上ie的httpRequest就可以了

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约