zoukankan      html  css  js  c++  java
  • Typical AJAX

    <html>
    <head>
    <script language="javascript">

     var xmlHttp = false;
     var e;
     function CreateDateSelect()
     {
      
      var html = [];

      for(var year=2008;year<=2008;year++)
      {
       for(var month=1;month<13;month++)
       {
        for(var day=1;day<32;day++)
        {
         html[html.length] = "<option value=\""+year+"\-"+month+"\-"+day+"\">"+year+"年"+month+"月"+day+"日"+"</option>";
        }
       }
      }
      document.getElementById("dateselect").innerHTML = "<select name=\"dateselect\" id=\"dateselect\" onchange=\"CallServer(this);\">"+html.join("")+"</select>";     
     }
     function getXMLHTTPObj()
     {
     
      var C = null;
      try
      {
       C = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e)
      {
       try
       {
        C= new ActiveXObject("Microsoft.XMLHTTP");
       }
       catch(sc)
       {
        C=null;
       }
      }
      if(!C && typeof XMLHttpRequest != "undefined")
      {
       C = new XMLHttpRequest();
      }
      return C;
     }
     function CallServer(e)
     {
      try
      {
       if(xmlHttp && xmlHttp.readyState != 0)
       {
        xmlHttp.abort();
       }
       xmlHttp = getXMLHTTPObj();
       if(xmlHttp)
       {
        //alert(e);
        var dateSelect = e.options[e.selectedIndex].value;
        
        document.getElementById("date").innerHTML= dateSelect+"开放式基金净值";
        var url="http://www.cc168.com.cn/service/FundNetValue.jsp?newEndDate="+dateSelect;
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = updatePage;
        xmlHttp.send(null);
       }
       else
       {
        document.getElementById("flag").innerHTML = "XMLHTTP Create Fail";
       }
      }
      catch(e)
      {
       document.getElementById("flag").innerHTML="select fail"+e;
      }
     }
     function updatePage()
     {
      try
      { 
       if(xmlHttp.readyState == 1)
       {
       document.getElementById("flag").innerHTML = "Loading object";
       }
       if(xmlHttp.readyState == 2)
       {
        document.getElementById("flag").innerHTML="Loading object finish";
       }
       if(xmlHttp.readyState == 3)
       {
        document.getElementById("flag").innerHTML="DOWNLOADING data...";
       }
       if(xmlHttp.readyState == 4)
       {
        document.getElementById("flag").innerHTML=xmlHttp.responseText;
       }
      }
      catch(e)
      {
      
      }
     }
    </script>
    </head>
    <body onload="CreateDateSelect();">
     <form>
      <div>请选择日期</div>
      <div>
       <div id="dateSelect" align="left"></div>
       <div id="flag" align="right"></div>
      </div>
      <div id="date"></div>
      <div id="outgroup">
       <div id="group1"></div>
       <div id="group2"></div>
       <div id="group3"></div>
       <div id="group4"></div>
      </div>
     </form>
    </body>
    </html>

  • 相关阅读:
    1、听说过Redis吗?它是什么?
    55、数据库高并发是我们经常会遇到的,你有什么好的解决方案吗?
    54、数据库如何保证持久性?
    53、数据库如何保证原子性?
    52、数据库如何保证一致性?
    注解定义、基本语法和属性
    Macbook 装机必备--开发篇
    http
    python:beaufiful
    python-yield
  • 原文地址:https://www.cnblogs.com/kevinge/p/1216792.html
Copyright © 2011-2022 走看看