页面代码
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script>
$(function () {
$("#btn").click(function () {
$.post("/One/Login", {
UserName: $("#Name").val(),
PassWord: $("#Password").val()
},
function (data) {
alert(data);
}
)
});
});
</script>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Login</title>
</head>
<body> <label>账号:</label><input type="text" id="Name" placeholder="请输入账号" />
<label>密码:</label><input type="password" id="Password" placeholder="请输入密码" />
<input id="btn" type="button" value="登录" /> </body>
控制器
public ActionResult Login(String UserName, string PassWord)
{ var UserPass=UserName+PassWord
return Json(UserPass); }