ITPub博客

首页 > > > $.ajax post 方式提交请求

$.ajax post 方式提交请求

作者:markriver 时间:2019-09-10 14:35:40 0 删除 编辑

问题:$.ajax post 方式提交请求,返回结果,为什么ashx程序已经执行完成,返回到error呢


前端代码

function examine(t)
        {
            $.ajax({
                type: 'post',
                url: 'Ashx/Examine.ashx?id=' + t,
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status + "----" + XMLHttpRequest.readyState + "----" + textStatus);
                },
                success: function (result) {
                    alert(result);
                }
            });
            location.reload();
        }

后台ashx

public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if(context.Request.QueryString["id"]==null)
            {
                context.Response.Clear();
                context.Response.Write("参数错误");
                context.Response.End();
            }
            else
            {
                string id = context.Request.QueryString["id"];
                if(SqlHelper.UserInfo.Examine(Convert.ToInt32(id)))
                {
                    context.Response.Clear();
                    context.Response.Write("审核通过");
                    context.Response.End();
                }
                else
                {
                    context.Response.Clear();
                    context.Response.Write("审核失败");
                    context.Response.End();
                }
            }
        }

ashx代码已执行,就是会返回error

另外用firebug断点调试的时候有时候可以

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/818/viewspace-3168701/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-07-03

  • 博文量
    502
  • 访问量
    18493