当我单击链接“Foo”时,我在 LogOn 操作中遇到了断点,但用户名始终为空。我不明白为什么。
<a class="jqselect" id="myId" href="#">Foo</a>
@using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { id = "fooForm" }))
{
<input type="text" id="username"/>
}
<script type="text/javascript">
$(document).ready(function () {
$(".jqselect").click(function () {
$.ajax({
url: '/Account/LogOn',
type: "Post",
data: $('#fooForm').serialize(),
success: function (result) {
if (result.success) {
}
}
});
});
});
</script>
[HttpPost]
public ActionResult LogOn(string username)
{
Console.WriteLine(username);
return new EmptyResult();
}