看法:
@{
AjaxOptions ajax = new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "sub_id" };
Layout = null;
}
<div id="sub_id"></div>
@using (Ajax.BeginForm(ajax))
{
@Html.TextBox("email");
<input type="submit" value="подписаться" />
}
控制器:
[HttpPost]
public ContentResult LeftMenuSubscription(string email)
{
return new ContentResult(){Content = "<script>alert('Thanks')</script>"};
}
“谢谢”警报节目。
但在 div 中sub_id
设置所有 page( <title></title><div>...</div>
)。
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
- 连接的。
html:
<html>
<head>
<title>Главная страница</title>
<link href="/Content/Site.css" rel="stylesheet" type="text/css">
<script src="/Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"</script>
<script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script src="/Scripts/jQueryFixes.js" type="text/javascript"></script>
</head>
<body>
....
<form action="/" data-ajax="true" data-ajax-method="POST" data-ajax-mode="replace" data-ajax-update="#sub_id" id="form0" method="post">
<input id="email" name="email" type="text" value="">
<input type="submit" value="подписаться">
</form>
....
</body>
</html>
可能是什么问题呢?