1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head runat="server">
3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
4 <title></title>
5 <script type="text/javascript">
6 onload = function () {
7 window.document.getElementById("Button1").onclick = function () {
8 var xhr = null
9 if (XMLHttpRequest) {
10 xhr = new XMLHttpRequest();
11 } else {
12 xhr = new ActiveXObject("Microsoft.XMLHTTP");//兼容IE6,IE5
13 }
14 xhr.open("get", "Handler2.ashx?a=bbb",true);
15 xhr.send();
16 xhr.onreadystatechange = function () {//回调函数
17 if(xhr.readyState==4){
18 if (xhr.status == 200) {
19 alert(xhr.responseText);
20 }
21 }
22 };
23
24 }
25
26 };
27
28 </script>
29 </head>
30 <body>
31 <form id="form1" runat="server">
32 <div>
33
34 <asp:Button ID="Button1" runat="server" Text="Button" />
35
36 </div>
37 </form>
38 </body>
39 </html>