随笔 - 115  文章 - 0  评论 - 0  阅读 - 40316

jquery调用一般处理程序的多个方法

 
复制代码
jquery调取方式:
<script type="text/javascript">
                            $(function () {
                                $.get("/Ashx/GetTraceabilityJson.ashx?" + new Date(), { 'ProductCode': '<%=ProductCode %>', 'BatchNumber': '<%=BatchNumber %>', 'command': 'GetFlowGraph' }, function (data) {
                                    if (data != null) {
                                        var data = $.parseJSON(decodeURIComponent(data));
                                        var nodes = eval(data[0].value);
                                        var links = eval(data[1].value);

                                        if (nodes.length > 0) {
                                            setNodes(nodes);
                                            setLinks(links);
                                        }
                                    }
                                });
                            });
                        </script>
复制代码

 

一般处理程序后台编写方法;

复制代码
/// <summary>
    /// GetTraceabilityJson 的摘要说明
    /// </summary>
    public class GetTraceabilityJson : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Request["command"] != null)
            {
                string command = context.Request["command"];
                System.Reflection.MethodInfo method = GetType().GetMethod(command);
                if (method != null)
                {
                    method.Invoke(this, new object[] { context });
                }
            }
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
        public void GetFlowGraph(HttpContext context)
        {
            string ProductCode = ParameterFilter.GetString(context.Request.QueryString["ProductCode"]);
            string BatchNumber = ParameterFilter.GetString(context.Request.QueryString["BatchNumber"]);
            if (string.IsNullOrEmpty(BatchNumber))
            {
                return;
            }

            //string a = "[{\"name\":\"node\",\"value\":\"[{'id': '0','name': '生产入库单:SC20131217000116', 'statue': 'Oval'},{'id': '1','name': '销售出库单:XS20131217000116', 'statue': 'Normal'},{'id': '5','name': '销售出库单:XS20131217000116', 'statue': 'Normal'},{'id': '6','name': '销售出库单:XS20131217000116', 'statue': 'Normal'},{'id': '7','name': '销售出库单:XS20131217000116', 'statue': 'Normal'},{'id': '2','name': '销售出库单:XS20131218000120', 'statue': 'Normal'},{'id': '3','name': '采购入库单:CG20131218000025', 'statue': 'Normal'},{'id': '4','name': '销售出库单:XS20131218000121', 'statue': 'Normal'}]\"},{\"name\":\"link\",\"value\":\"[{'name': '','target': '1','source': '0'},{'name': '','target': '2','source': '0'},{'name': '','target': '3','source': '2'},{'name': '','target': '4','source': '3'},{'name': '','target': '5','source': '0'},{'name': '','target': '6','source': '0'},{'name': '','target': '7','source': '0'}]\"}]";



            JavaScriptSerializer jss = new JavaScriptSerializer();
            Node[] values = new Node[]
            {
                new Node() { name = "node", value = ("[" + sbNodes.ToString().TrimEnd(',') + "]") }, 
                new Node() { name = "link", value = ("[" + sbNodeLinks.ToString().TrimEnd(',') + "]") }
            };
            context.Response.ContentType = "text/plain";
            string json = jss.Serialize(values);
            context.Response.Write(json);
            context.Response.End();

        }
复制代码

 

posted on   wuzx-blog  阅读(1088)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示