测试代码折叠

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <script type="text/javascript">
        function createXmlHttpRequest(){
            try{
                return new XMLHttpRequest();
            }catch(e){
                try{
                    return new ActiveXObject("Msxml2.XMLHTTP");
                }catch(e){
                    try{
                        return new ActiveXObject("Micorsoft.XMLHTTP");
                    }catch(e){
                        throw e;
                    }
                }
            }
        }
        window.onload = function(){
            var btn = document.getElementById("btn");
            btn.onclick = function(){
                
            var xmlHttp = createXmlHttpRequest();
            xmlHttp.open("GET", "/ajaxdemo/AServlet",true);
            xmlHttp.send(null);
            xmlHttp.onreadystatechange = function(){
                if(xmlHttp.status == 200 && xmlHttp.readyState == 4){
                    var text = xmlHttp.responseText;
                    var h1 = document.getElementById("h1");
                    h1.innerHTML = text;
                }
            }
        }
    }
            
    </script>
  </head>
  
  <body>
    <button id="btn">点击这里</button>
    <h1 id="h1"></h1>
  </body>
</html>
Demo.html

 

posted on 2017-10-26 11:57  OrangeCsong  阅读(125)  评论(0编辑  收藏  举报

导航