123456789101112131415161718192021222324252627282930313233343536373839 |
- <!DOCTYPE html>
- <html>
- <head>
- <script type="text/javascript">
- function ajaxFunction()
- {
- var xmlhttp;
- //判断浏览器
- if (window.XMLHttpRequest)
- {
- xmlhttp=new XMLHttpRequest();
- }
- else
- {
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- //每当readyState 改变时,就会触发 onreadystatechange 事件
- xmlhttp.onreadystatechange=function()
- {
- if (xmlhttp.readyState==4 && xmlhttp.status==200)
- {
- document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
- }
- }
- //XMLHttpRequest.open('post', url, true);
- xmlhttp.open("post","visit.jsp",true);
- //在利用xmlhttp的send()提交表格,并且需要在服务器端通过request.getParameter("paraName")来就收的话,先要加入header参数
- xmlhttp.send();
- }
-
- </script>
- </head>
- <body>
- <button type="button" onclick="ajaxFunction()" >点击刷新访客量</button>
- <div id="myDiv"></div>
- </body>
- </html>
|