怎样取出或返回success中的数据
2个回答
展开全部
用AjaxPro吧和后端交互很方便的。js获取后端返回值和js传值给后端的ajax方法都很方便。
/// <summary>
/// 获取当前登录用户的权限明细
/// </summary>
/// <returns></returns>
[AjaxMethod]
public List<string> GetPermission()
{
Guid userID = new Guid(Session["UserID"] as string);
using(var db = new TWSDBEntities())
{
var userEntity = db.SystemUserEntity.Where(u => u.UserKeyID == userID).FirstOrDefault();
userEntity.SystemRoleEntityReference.Load();
var roleID = userEntity.SystemRoleEntity.RoleKeyID;
var list = db.RolePermissionEntity.Where(p => p.RoleKeyID == roleID).ToList();
List<string> resultList = new List<string>();
foreach(RolePermissionEntity roleItem in list)
{
resultList.Add(roleItem.PermissionID.ToString().ToUpper());
}
return resultList;
}
}
前端js:
var array = {};
array =
后端命名空间.页面分部类名.方法名();
/// <summary>
/// 获取当前登录用户的权限明细
/// </summary>
/// <returns></returns>
[AjaxMethod]
public List<string> GetPermission()
{
Guid userID = new Guid(Session["UserID"] as string);
using(var db = new TWSDBEntities())
{
var userEntity = db.SystemUserEntity.Where(u => u.UserKeyID == userID).FirstOrDefault();
userEntity.SystemRoleEntityReference.Load();
var roleID = userEntity.SystemRoleEntity.RoleKeyID;
var list = db.RolePermissionEntity.Where(p => p.RoleKeyID == roleID).ToList();
List<string> resultList = new List<string>();
foreach(RolePermissionEntity roleItem in list)
{
resultList.Add(roleItem.PermissionID.ToString().ToUpper());
}
return resultList;
}
}
前端js:
var array = {};
array =
后端命名空间.页面分部类名.方法名();
展开全部
用AjaxPro把和后端交互很方便的。js获取后端返回值和js传值给后端的ajax方法都很方便。
/// <summary>
/// 获取当前登录用户的权限明细
/// </summary>
/// <returns></returns>
[AjaxMethod]
public List<string> GetPermission()
{
Guid userID = new Guid(Session["UserID"] as string);
using(var db = new TWSDBEntities())
{
var userEntity = db.SystemUserEntity.Where(u => u.UserKeyID == userID).FirstOrDefault();
userEntity.SystemRoleEntityReference.Load();
var roleID = userEntity.SystemRoleEntity.RoleKeyID;
var list = db.RolePermissionEntity.Where(p => p.RoleKeyID == roleID).ToList();
List<string> resultList = new List<string>();
foreach(RolePermissionEntity roleItem in list)
{
resultList.Add(roleItem.PermissionID.ToString().ToUpper());
}
return resultList;
}
}
前端js:
var array = {};
array = 后端命名空间.页面分部类名.方法名();
/// <summary>
/// 获取当前登录用户的权限明细
/// </summary>
/// <returns></returns>
[AjaxMethod]
public List<string> GetPermission()
{
Guid userID = new Guid(Session["UserID"] as string);
using(var db = new TWSDBEntities())
{
var userEntity = db.SystemUserEntity.Where(u => u.UserKeyID == userID).FirstOrDefault();
userEntity.SystemRoleEntityReference.Load();
var roleID = userEntity.SystemRoleEntity.RoleKeyID;
var list = db.RolePermissionEntity.Where(p => p.RoleKeyID == roleID).ToList();
List<string> resultList = new List<string>();
foreach(RolePermissionEntity roleItem in list)
{
resultList.Add(roleItem.PermissionID.ToString().ToUpper());
}
return resultList;
}
}
前端js:
var array = {};
array = 后端命名空间.页面分部类名.方法名();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询