-
-
- <script type="text/javascript">
- var xmlHttp;
- function createXMLHttpRequest()
- {
- if(window.ActiveXObject)
- {
- xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- }
- else if(window.XMLHttpRequest)
- {
- xmlHttp = new XMLHttpRequest();
- }
- }
- function startRequest()
- {
- createXMLHttpRequest();
- xmlHttp.onreadystatechange = handleStateChange;
- xmlHttp.open("GET","response.xml",true);
- xmlHttp.send(null);
- }
- function handleStateChange()
- {
- if(xmlHttp.readyState==4)
- {
- if(xmlHttp.status==200)
- {
- alert("来自服务器的响应:"+xmlHttp.responseText);
- }
- }
- }
- </script>
- <body>
- <form id="form1" runat="server">
- <div style="text-align: center">
- <input id="Button1" style="width: 85px" type="button" value="发送请求" οnclick="startRequest();" /> </div>
- </form>
- </body>
- response.xml 的内容:“我是服务器!收到没?”
简单的一个AJAX示例
最新推荐文章于 2020-06-30 14:40:28 发布