zoukankan      html  css  js  c++  java
  • ASP.NET AJAX调用 WebService


    同事的代码,帮忙修改的,为了实现页面跳转回来后,状态的保持,Service 使用了Session。

    主要的JS $.ajax({ url:
    "/ws/StaffInfo.asmx/Note",//路径/方法 type: "POST", contentType: "application/json", data: "{id:'" + id + "',sex:'" + sex + "',dep:'" + dep + "',sql:'" + sql + "',page:'" + page + "'}", dataType: "json", success: function (res) { //var th = res.d; //alert(th); window.open("AddStaffInfo.aspx?id=" + getid + "", "_self"); }, error: function (XMLHttpRequest, textStatus, errorInfo) { alert("请求失败"); } //error: function (data) { // alert("请求失败"); //} }); //此处使用 Session,必须加的特性 [WebMethod(EnableSession = true)] public string Note(string id, string sex, string dep, string sql,string page) { Session["WebServiceStaffIsopen"] = true; Session["WebServiceStaffId"] = id; Session["WebServiceStaffSex"] = sex; Session["WebServiceStaffDep"] = dep; Session["WebServiceStaffPage"] = page; string s = Microsoft.JScript.GlobalObject.unescape(sql); Web.StaffInfo.Id = id; Web.StaffInfo.Sex = sex; Web.StaffInfo.Dep = dep; Web.StaffInfo.Sql = s; Web.StaffInfo.Index = page; Web.StaffInfo.Isopen = true; if (s.Trim().ToLower() == "true") { Web.StaffInfo.Sql = "1=1"; Session["WebServiceStaffSql"] = "1=1"; } else { Web.StaffInfo.Sql = s; Session["WebServiceStaffSql"] = s; } return s + id + sex + dep + page; }
  • 相关阅读:
    ThreadLocal
    mysql
    heroku 的用法
    Redis
    disruptor
    RxJava
    TCP
    虚拟机的安装及配置等
    k8s
    Ribbon源
  • 原文地址:https://www.cnblogs.com/aswater-yuanye/p/3535003.html
Copyright © 2011-2022 走看看