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 ("comment succeeded");
JQuery ("#message"). Val ("");
Window.location.href = "jd-" + Appraisalid + ". html";
}
else {
Alert ("comment failed");
}
}
}, Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
Alert ("Error");
},
});
}
}
}
}
});
C#
public override Object ProcessRequest ()
{
if (action = = "addcomment")
{
Get logged in user
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 ();//Check login and return user name
}
return null;
}
. NET generic handlers complete AJAX operations