使用OpearteResult公共类
使用session引用using System.Web.SessionState;
继承IRequiresSessionState
获取context.Session["name"].ToString();
如果成功,那么就 return new OpearteResult(ResultStatus.Success, "添加成功");
然后转换为json格式
context.Response.Write(new JavaScriptSerializer().Serialize(result(num, info, name, card)));
需要引用:
using System.Web.Script.Serialization;
前台接收:
$.ajax({
type: "post",
url: "ashx/FIleShow.ashx",
data: { "num": i, "status": "0", "info": id },
dataType: "json",
success: function (data) {
if (data.ResultStatus == 1) {
alert("添加成功");
} else {
alert("添加失败");
}
}
});