zoukankan      html  css  js  c++  java
  • JQUREY 调用 shax

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="JqueryDemoTest.WebForm2" %>
    
    <!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 runat="server">
        <title></title>
        <script src="js/jquery-1.4.1.min.js" type="text/javascript"></script>
        <script src="js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $('#btn').click(function () {
                    $.post('Handler.ashx', { val: $("#<%=ddlMain.ClientID %>").val() }, function (data) {
                        var json = eval(data);
                        var html = '';
                        for (var i in json) {
                            html += '<option value="' + json[i].Value + '">' + json[i].Name + '</option>';
                        }
                        $("#<%=ddlSub.ClientID %>")[0].options.length = 0;
                        $(html).appendTo($("#<%=ddlSub.ClientID %>"));
    
                    });
    
                });
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
           <asp:DropDownList ID="ddlMain" runat="server">
            <asp:ListItem Text="一级城市" Value="1"></asp:ListItem>
            <asp:ListItem Text="旅游城市" Value="2"></asp:ListItem>
        </asp:DropDownList>
        <asp:DropDownList ID="ddlSub" runat="server">
        </asp:DropDownList>
        <input type="button" id='btn' value='click me' />
        </div>
        </form>
    </body>
    </html>
    
    

    code ashx

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace JqueryDemoTest
    {
        /// <summary>
        /// Summary description for Handler
        /// </summary>
        public class Handler : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
    
                string json = string.Empty;
    
                if (context.Request.Form["val"] == "1")
                {
                    json = "[{\"Name\":\"北京\",\"Value\":1},{\"Name\":\"深圳\",\"Value\":2},{\"Name\":\"上海\",\"Value\":3}]";
                }
                else if (context.Request.Form["val"] == "2")
                {
                    json = "[{\"Name\":\"杭州\",\"Value\":4},{\"Name\":\"苏州\",\"Value\":5},{\"Name\":\"桂林\",\"Value\":6}]";
                }
    
                context.Response.Write(json);
                context.Response.End();
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
    
  • 相关阅读:
    python等缩进语言的词法分析实现
    收集Android程序测试代码覆盖率
    对语言之争的看法
    关于asmlinkage
    洛谷 P4171 [JSOI2010] 满汉全席(2sat)
    Codeforces Round #748 (Div. 3)解题报告
    洛谷 P1712 [NOI2016] 区间(尺取法、线段树)
    洛谷 P4782 【模板】2SAT 问题
    洛谷 P3513 [POI2011]KONConspiracy(2sat方案数)
    梦见和深爱的女孩牵着手,竟然从梦中幸福惊醒,醒后一片悲伤~~
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/1778338.html
Copyright © 2011-2022 走看看