【发布时间】:2010-11-17 01:11:05
【问题描述】:
<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>
【问题讨论】:
-
您可以尝试使用浏览器中的开发者工具对其进行调试。在 IE8 中你可以使用 F12 来启动它,在 Chrome 中它是 Ctrl+Shift+I,在 FireFox 中通常大多数人使用 firebug。
标签: asp.net ajax asp.net-ajax