阅读背景:

为什么这个AJAX代码在ASP.NET中没有显示任何输出?

来源:互联网 
<head runat="server">
<script type ="text/javascript">
   function LoadXMLDoc()
   {
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {
            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                document.getElementById("Div1").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","ajax_info.txt",true); //this text file is in the same folder
        xmlhttp.send();
    }

</script>

<body>
    <form id="form1" runat="server">
        <div id="Div1"><h2>How Ajax works</h2></div>
    <button type="button" onclick="LoadXMLDoc()">Change Content</button>

   </form>
</body>
<head runat="server">
<script type ="text/javas



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: