兄弟伙我的OnSuccess="afterLogin"咋调用不起,直接返回return Content类容到页面
@{
Layout = null;
}
<!DOCTYPE html>
网上超市管理系统
</p> <pre><code> //就是执行controller方法以后执行的方法 function afterLogin(data) { alert('ddd'); var serverData = data.split(':');//获得什么呢 返回的值!content if (serverData[0] == "ok") { window.location.href = "/Manage/Index" } else if (serverData[0] == "no") { $("#msg").text(serverData[1]);//.text赋值 } else { window.location.href = "/Error.html" //错误显示的页面 } } </script> </code></pre> <p></head><br> <body><br> <div id="big"><br> <div id="content"><br> <div class="logo"><img src="~/Content/Style/images/logo.gif" /></div><br> <div class="title">网上超市管理系统</div><br> <div style="position:absolute;margin:0px 0 0 0px;"></p> <pre><code> @using (Ajax.BeginForm("CheckLogin", new { }, new AjaxOptions() { HttpMethod = "post", OnSuccess="afterLogin" }, new { id = "loginForm" })) { <table class="tab"> <tr> <td class="txt_left" >User&nbsp;Id:</td> <td><input type="text" class="txt_right" name="name" value="" id="name"/></td> </tr> <tr> <td class="txt_left">Password:</td> <td><input type="password"name="pwd" class="txt_right" value="" id="pwd" /></td> </tr> <tr> <td style="color:#ea728c;font-style:oblique;text-decoration:underline;padding-left:40px" id="msg"></td> <td>&nbsp;</td> </tr> <tr> <td><button id="login" type="submit" class="btnlog" style="margin:14px 0 0 13px;">&nbsp;</button></td> <td><input type="submit" class="btncle" value=" " id="clerr" style="margin:14px 0 0 29px;" /></td> </tr> </table> } </div> <div><img src="~/Content/Style/images/tu1.jpg" style="position:absolute;margin:10px 0 0 440px;" /></div> </div> </div> </code></pre> <p></body><br> </html></p> <pre><code> public ActionResult CheckLogin() { string name = Request["name"]; string pwd = Request["pwd"]; //if (bll.Select(name, pwd)==1) //{ // return RedirectToAction("Index");//和View("Index")都是可以的! //} CHEN.Model.UserModel usermodel = new CHEN.Model.UserModel(); usermodel = bll.GetModel(name); if (usermodel != null) { if (usermodel.pwd != pwd) { return Content("no:密码不正确!"); } else { return Content("ok:登录成功!!"); } } else { return Content("nono:没有找到!"); } } </code></pre>