ajax 常用模板

来源:互联网 发布:123软件 编辑:程序博客网 时间:2024/06/05 18:01
<script type="text/javascript">    function loadXMLDoc() {        var xmlhttp;        if (window.XMLHttpRequest) {            xmlhttp = new XMLHttpRequest();        }        else {            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");        }        xmlhttp.open("GET", "input.txt", true);        xmlhttp.send();        <!--            xmlhttp.open("POST","ajax_test.asp",true);            xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");            xmlhttp.send("fname=Bill&lname=Gates");        -->        xmlhttp.onreadystatechange = function () {            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {                document.getElementById("myDiv").innerHTML = xmlhttp.responseText;            }        }    }</script>
1 0