MyHtml.html
<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
function Ajax (url,fnSucc,fnFail){
//1.创建Ajax对象 虽然我们老说Ajax 但在浏览器中XMLHttpRequest才是真正的对象
var Ajax = new XMLHttpRequest();
//2.连接到服务器 open(提交方式,文件名,异步传输)
Ajax.open("POST", url + "?t=" + new Date().getTime(), true);
//3.发送请求
Ajax.send();
//4.接受返回
Ajax.onreadystatechange = function (){
if(Ajax.readyState == 4)//4代表send方法完成,收到全部相应内容并且完成解析
{
if(Ajax.status == 200){
fnSucc(Ajax.responseText);
}else{
if(fnFail)
fnFail(Ajax.status);
}
}
};
};
window.onload = function (){
var oBtn = document.getElementById("btn");
oBtn.onclick = function(){
Ajax("aaa.txt",
function(message){alert(message);}
);
};
};
</script>
Login: | |
Password: | |