zoukankan      html  css  js  c++  java
  • AJAX页面局部调用

    <script>
    function gb2utf8(data){
     var glbEncode = [];
     gb2utf8_data = data;
     execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript");
     var t=escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
     t=t.split("@");
     var i=0,j=t.length,k;
    while(++i<j) {
     k=t[i].substring(0,4);
     if(!glbEncode[k]) {
      gb2utf8_char = eval("0x"+k);
      execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
      glbEncode[k]=escape(gb2utf8_char).substring(1,6);
      }
      t[i]=glbEncode[k]+t[i].substring(4);
     }
     gb2utf8_data = gb2utf8_char = null;
     return unescape(t.join("%"));
    }
    function ajaxSubmit2(){
     document.getElementById("loginstate").innerHTML = "<center><img src='images/load01.gif'></center>";
     //创建XMLHttpRequest对象
     var xmlhttp;
     try{
      xmlhttp=new XMLHttpRequest();
     }catch(e){
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
      xmlhttp.onreadystatechange=function(){
       if (4==xmlhttp.readyState){
        if (200==xmlhttp.status){
         var content=gb2utf8(xmlhttp.responseBody);
         document.getElementById("loginstate").innerHTML = content;
        }else{
        alert("error");
        }
       }
      }
     //打开连接,true表示异步提交
     xmlhttp.open("post","time.php?id=1", true);
     //当方法为post时需要如下设置http头
     xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
     //发送数据
     xmlhttp.send(null);
    }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>

    <body>
    <div id="loginstate"></div>
    <script language="javascript">ajaxSubmit2();</script>
    </body>
    </html>

  • 相关阅读:
    [bzoj4408][Fjoi2016]神秘数
    BZOJ1102: [POI2007]山峰和山谷Grz
    BZOJ1098: [POI2007]办公楼biu
    BZOJ1097: [POI2007]旅游景点atr
    GDOI2018 新的征程
    BZOJ2084: [Poi2010]Antisymmetry
    回文树详解
    Codeforces739E. Gosha is hunting
    一道题17
    LOJ#6002. 「网络流 24 题」最小路径覆盖
  • 原文地址:https://www.cnblogs.com/tdalcn/p/2010359.html
Copyright © 2011-2022 走看看