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;

        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值