日期:2014-05-16  浏览次数:20433 次

ajax 传参
从后台传过来的时候,接不到十怎么回事
    success: function (data) {
                         if (data == "0")
                             $('#result').html("登录成功");
                         if (data == "-1")
                             $('#result').html("用户名密码错误");
                     },

 if (context.Request["action"] == "log")
            {
                if (new bbs.business.userinfobll().getuserinfo(name, passwd).Rows.Count > 0)
                {
                    context.Response.Write("0");
                }
                else
                {
                    context.Response.Write("-1");
                }
            }

------解决方案--------------------
1.保证ajax的请求路径无误
2.断点跟踪看是否正确执行到了context.Response.Write
3.弹出data看一下 内容是什么
4.如果没有进入sucess,那么尝试在error方法中捕获异常

不过据我估计,可能后台返回的值 并不是单纯的0和-1

一般会做如下处理 
context.Response.Clear();
        context.Response.Write("1");
        context.Response.Flush();