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();
            }

  • 相关阅读:
    Julia出现错误ERROR: LoadError: syntax: try without catch or finally
    tensorflow白话篇
    论秋招中的排序(排序法汇总-------中篇)
    论秋招中的排序(排序法汇总-------上篇)
    红包的收益(笔试)
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli2/Option
    Spark 贝叶斯分类算法
    centos php Zookeeper kafka扩展安装
    SpringBoot tomcat
    flume 整合kafka
  • 原文地址:https://www.cnblogs.com/zhuawang/p/2101397.html
Copyright © 2011-2022 走看看