ajax 第一个程序

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script>
window.onload = function ()
{
    var obtn = document.getElementById('btn');
    
    obtn.onclick = function ()
    {
        var xhr = new XMLHttpRequest();
        xhr.open('GET','1.txt',true);
        xhr.send();
        xhr.onreadystatechange = function ()
        {
            if(xhr.readyState = 4)
            {
                alert(xhr.responseText);
            }
        }
    }
}
</script>
</head>

<body>
<input type="button" id="btn" value="提交">
</body>
</html>

 

posted @ 2015-02-19 23:34  mayufo  阅读(157)  评论(0编辑  收藏  举报