码迷,mamicode.com
首页 > 编程语言 > 详细

javascript ajax请求

时间:2016-01-14 22:10:36      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <meta charset="utf-8" />

</head>
<body>
    <input id="btn1" type="button" value="提交" />
    <script type="text/javascript">
        var oBtn = document.getElementById("btn1");
        oBtn.onclick = function () {
            var oAjax = null;
            if (window.XMLHttpRequest) {
                oAjax = new XMLHttpRequest();
            } else {
                oAjax = new ActiveXObject("");
            }
            oAjax.open("get", "aaa.txt", true);
            oAjax.send();
            oAjax.onreadystatechange = function () {
                if (oAjax.readyState == 4) {
                    if (oAjax.status == 200) {
                        alert(oAjax.responseText);
                    }
                }
            };
        };
    </script>
</body>
</html>

 

javascript ajax请求

标签:

原文地址:http://www.cnblogs.com/chao2014/p/5131714.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!