继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

java ajax 整个过程..

Curtis_yang
关注TA
已关注
手记 63
粉丝 62
获赞 1091

<script type="text/javascript">
window.onload = function() {
document.getElementsByTagName("a")[0].onclick = function() {

        var request = new XMLHttpRequest();
        var method = "GET";
        var url = this.href + "?time=" + new Date();

        request.open(method, url);
        request.send(null);

        request.onreadystatechange = function() {
            if (request.readyState == 4) {
                if (request.status == 200 || request.status == 304) {
                    alert(request.responseText);
                }
            }
        }
        return false;
    }
}

</script>
</head>
<body>
<a href="hello.txt">Ajax hello.txt</a>
</body>

打开App,阅读手记
1人推荐
发表评论
随时随地看视频慕课网APP

热门评论

<title>Ajax post</title>

<script type="text/javascript">

window.onload = function() {

document.getElementsByTagName("a")[0].onclick = function() {

var request = new XMLHttpRequest();

var method = "POST";

var url = this.href + "?time=" + new Date();

request.open(method, url);

request.setRequestHeader("ContentType", "application/x-www-form-urlencoded");

request.send("name='a'");

request.onreadystatechange = function() {

if (request.readyState == 4) {

if (request.status == 200 || request.status == 304) {

alert(request.responseText);

}

}

}

return false;

}

}

</script>

</head>

<body>

<a href="hello.txt">Ajax hello.txt</a>

</body>


查看全部评论