zoukankan      html  css  js  c++  java
  • jquery+ajax+asp.net简例

    客户端:

    $.ajax(
                            {
                                type: "POST",
                                url: "SaveRole.aspx?oid=" + $("#hdOperatorId").val() + "&role=" + role,
                                data: "formData1=1&formData2=2",

        //async: false, 同步

                                success: function(mes) {
                                    if (mes != "") {

                                        if (mes == "fail") {
                                            //保持失败

                                        } else {
                                            //保存成功
                                            alert("保持成功");
                                            window.location.href = "OperatorList.aspx";
                                        }

                                    } else {
                                        //$("#divResult").text("程序出错,请重新启动");
                                    }
                                },
                                error: function() {
                                    alert("error");
                                }
                            });

    ------------------------------

    服务器:

     protected void Page_Load(object sender, EventArgs e)
            {
                string OperatorId = Request.QueryString["oid"];
                string role = Request.QueryString["role"];

                string formData1=Request.Form["formData1"];

                string formData2=Request.Form["formData2"];


                int ret = 0;
                if (string.IsNullOrEmpty(role))
                {
                    ret = ServiceFactory.OperatorService.SetRole(long.Parse(OperatorId), "");
                }
                else
                {
                    string[] arr = role.Split(new char[] { ',' });

                    System.Text.StringBuilder sb = new System.Text.StringBuilder("");
                    for (int i = 0; i < arr.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(arr[i]))
                            sb.AppendFormat("<cus OperatorId=\"{0}\" RoleId=\"{1}\"/>", OperatorId, arr[i]);
                    }

                    ret = ServiceFactory.OperatorService.SetRole(long.Parse(OperatorId), sb.ToString());
                }
                if (ret >= 0)
                    Response.Write("success");
                else
                    Response.Write("fail");


                Response.End();
            }

  • 相关阅读:
    6_10 下落的树叶(UVa699)<二叉树的DFS>
    6_9 天平(UVa839)<二叉树的DFS>
    6_8 树(UVa548)<从中序和后序恢复二叉树>
    6_7 树的层次遍历(UVa122)<二叉树的动态创建与BFS>
    6_6 小球下落(UVa679)<完全二叉树编号>
    6_4 破损的键盘(UVa11988)<链表>
    6_3 矩阵链乘(UVa424)<用栈实现简单的表达式解析>
    6_2 铁轨(UVa514)<栈>
    第五周课程总结&试验报告(三)
    第四周课程总结和实验报告
  • 原文地址:https://www.cnblogs.com/zhuawang/p/2101397.html
Copyright © 2011-2022 走看看