zoukankan      html  css  js  c++  java
  • jquery 异步获取数据 实例

    此时没有详细的解释说明  有不清楚的地方可加我qq 873247758

    前台:

     function ListNoUseCode() {//type: $('#<%=ArchiveTypeList.ClientID %>').val()
                $.get("GetCodeHander.ashx", { get: "list", type: $('#<%=ArchiveTypeList.ClientID %>').val(), year: $('#<%=YearList.ClientID %>').val(), mid: $('#<%=DocTypeNameList.ClientID %>').val(), userid: "<%=CurrentUser.UserId.ToString() %>", refresh: Math.random() },
                  function(data) {
                      //alert("Data Loaded: " + data);
                      $("#DropDownMenu").empty();
                      var strlist = data.split(',');
                      for (var i = 0; i < strlist.length; i++) {
                          if (data == "") {
                              $("<li class='dorpDownA'>无断号发文</li>").appendTo("#DropDownMenu").click(function() {
                                  window['DownDisDiv'].toggleDisplay($("#DropDownMenu").get(0), "none");
                              });
                          }
                          else {
                              var str = strlist[i].split("|");
                              var title = str;
                              var strClass = "dorpDownA";
                              if (str[1] != undefined) {
                                  title = str[1];
                                  strClass = "dorpDownB";
                              }
                              var no = (1000 + parseInt(str[0], 10)).toString().substr(1, 3);
                              $("<li title='" + title + "' value='" + no + "' class='" + strClass + "'>文号:" + no + "</li>").appendTo("#DropDownMenu").click(function() {
                                  var v = (1000 + parseInt($(this).attr('value'), 10)).toString().substr(1, 3);
                                  $("#<%=TextBoxArchivesCode.ClientID %>").val(v);
                                  window['DownDisDiv'].toggleDisplay($("#DropDownMenu").get(0), "none");
                              }).mouseover(function() {
                                  $(this).addClass('Codehover');
                              }).mouseout(function() {
                                  $(this).removeClass('Codehover');
                              });
                          }
                      }
                      window['DownDisDiv'].setDiv($("#<%=TextBoxArchivesCode.ClientID %>").get(0), $("#DropDownMenu").get(0));
                      //window['DownDisDiv'].toggleDisplay($("#DropDownMenu").get(0), "");
                  });
            }

    GetCodeHander.ashx 代码:

     public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            #region 清除缓存
            context.Response.Expires = 0;
            context.Response.Cache.SetNoStore();
            context.Response.AppendHeader("Pragma", "no-cache");
            #endregion

            //请求类型
            string appid = context.Request.Params["appid"] != null ? context.Request.Params["appid"].ToString() : "";
            string rtype = context.Request.Params["get"] != null ? context.Request.Params["get"].ToString() : "";
            string atype = context.Request.Params["type"] != null ? context.Request.Params["type"].ToString() : "";
            string year = context.Request.Params["year"] != null ? context.Request.Params["year"].ToString() : "";
            string mid = context.Request.Params["mid"] != null ? context.Request.Params["mid"].ToString() : "";
            string userid = context.Request.Params["userid"] != null ? context.Request.Params["userid"].ToString() : "";
            string systemcode = context.Request.Params["systemcode"] != null ? context.Request.Params["systemcode"].ToString() : "";
            switch (rtype)
            {
                case "max":
                    context.Response.Write(sendCode.GetMaxCodeByType_Year(appid, atype, Convert.ToInt16(year), systemcode, userid));
                    break;
                case "list":
                    ReservationNumber service = new ReservationNumber();
                    DataTable dt = service.GetAllNumber("fwxt", atype, year, userid);
                    context.Response.Write(string.Join(",", sendCode.GetCutCodeByType_Year(atype, Convert.ToInt16(year), mid, dt).ToArray()));
                    break;
                case "title":
                    context.Response.Write(sendCode.GetCaptionTitle(atype) + "|" + sendCode.GetForWordTitle(atype)+"|" + sendCode.GetCaptionUnit(atype));
                    break;
                default:
                    context.Response.Write("param error");
                    break;
            }
        }

  • 相关阅读:
    关于技术开发部员工培训文稿
    关于CLR、CIL、CTS、CLS、CLI、BCL和FCL
    MSIL(IL)百科
    汇编百科
    exe文件百科
    解释一下.net平台的语言无关性和语言继承性
    关于视频流媒体服务器的学习记录
    Ubuntu18.04的下载与安装(全过程纪录)
    记主板的南桥芯片和北桥芯片作用及区别(“干南桥”)
    我的Java资料小栈-START
  • 原文地址:https://www.cnblogs.com/suwh/p/2544597.html
Copyright © 2011-2022 走看看