和ajax相关

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>     <head>         <title>count.html</title>         <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">         <meta http-equiv="description" content="this is my page">         <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style type="text/css">     .test0 {display:block;color:blue;background-color:red;border000 1px solid;z-index:1000;position:absolute;width:1024px;left:20px;top:70px;height:20} </style>     </head>     <script language="javascript">        var indd;               function test(){            var sel=document.getElementById("sel").value;           var but0 =  document.getElementById("but");           var xh;           var count="";           var div =  document.getElementById("tx");           var m="";         xh = new ActiveXObject("Microsoft.XMLHTTP") ;      if(but0.value=="stop"){           xh.onreadystatechange = function ()         {               if (xh.readyState == 4)          {           indd = xh.responseText;          div.innerText = indd;                        setTimeout("test();",1000);          }          }         }else{         xh.onreadystatechange = function (){         }         }         m="http://127.0.0.1080/test/servlet/test?in="+indd+"&sel="+sel ;         xh.open("POST",m,true) ;         xh.send();         }     function st_spf(){        var but0 =  document.getElementById("but");         var but =  document.getElementById("tx");         if(but0.value=="start"){          but0.value= "stop";          test()         }else{         but0.value = "start";         }         }    </script>     <body >     <br><center>计数器小程序,用AJAX技术实现,后台使用SEVLET技术支持</center><br>tesdjs<br>tesdjs<br>tesdjs         <div id="tx" class="test0" >             start         </div>         <br><br>         <center><input type='button' id='but' value='start' οnclick="st_spf();" />         <select id="sel" ><option value="jia" selected="selected">加</option>         <option value="jian">减</option></select></center>     </body> </html> //Servlet后台 public void doGet(HttpServletRequest request, HttpServletResponse response)             throws ServletException, IOException {                  ServletOutputStream out = response.getOutputStream();          int i=0;          String in=request.getParameter("in");          String sel=request.getParameter("sel");          if("undefined".equals(in)||in==null){              in= Integer.toString(i);          }          else{              i= Integer.parseInt(in);              if(sel.equals("jia")){                  in = Integer.toString(++i);              }else{              in = Integer.toString(--i);              }          }          out.print(in);     } //dopost调用doget     public void doPost(HttpServletRequest request, HttpServletResponse response)             throws ServletException, IOException {         this.doGet(request, response);     }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值