.NET 一般处理程序完成AJAX操作
jQuery("#btn").click(function () {
var commentMessahe = jQuery("#CommentNote").val();
var num = jQuery("#CommentNote").val().length;
if (username != "") {
if (commentMessahe != "") {
if (falgText) {
if (isvalidatecode) {
jQuery.ajax({
type: "Post",
url: "http://www.taogujie.com/Handler/JDCommentlHander.ashx?jd=AddComment",
data: { AppraisalID: appraisalID, CommentNote: commentMessahe },
success: function (data) {
if (data.isok) {
if (data.result == 1) {
alert("评论成功");
jQuery("#message").val("");
window.location.href = "jd-" + appraisalID + ".html";
}
else {
alert("评论失败");
}
}
}, error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("错误");
},
});
}
}
}
}
});
C#
public override object ProcessRequest()
{
if (action == "AddComment")
{
//获取登录用户
WBMall.Business.SSO.UserCookiesService userCookieService = new WBMall.Business.SSO.UserCookiesService();
ResultInfo<WBMall.Model.Common.SmallUserInfo> results = userCookieService.CheckLogin();
string uName = "";
string uId = "";
if (results.Result)
{
uName = results.Data.Account;
uId = results.Data.Code;
}
string commentNote = HttpPageHelper.RequestString("CommentNote");
int appraisalID = HttpPageHelper.RequestInt("AppraisalID");
AppraisalCommentModel model = new AppraisalCommentModel();
model.AppraisalID = appraisalID;
model.CommentNote = commentNote;
model.IP = WBMall.PMethod.Users.GetIP();
model.CreateTime = DateTime.Now;
model.ComUserID =int.Parse(uId.ToString());
model.ComUserName = uName.ToString();
model.IsDelete = false;
model.IsShow = false;
model.AdminID = 1;
var result = jdbll.AddAppraisalComment(model);
if (result.Result)
{
if (result.Data) { return 1; } else { return 0; }
}
}
else if (action == "checkvalidate")
{
if (CheckValidateCode()) { return 1; } else { return 0; }
}
else if (action == "checklogin")
{
return CheckLogin();//检查是否登录并且返回用户名
}
return null;
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。