我是MVC的新手,我在提交表单后尝试更新我的页面; 但它不起作用.我只是试图隐藏表单,并显示div OnSuccess的内容.
我的代码是:
<script type="text/javascript">
$(document).ready(function () {
$('#confirmation').hide();
});
function MessageConfirmation() {
$('#confirmation').show('slow');
$('#contactForm').hide('slow');
}
</script>
@using (Ajax.BeginForm("Index", new AjaxOptions { OnSuccess = "MessageConfirmation" }))
{
<fieldset id="contactForm">
<legend>Message</legend>
<p>
@Html.Label("Email", "Email"): @Html.TextBox("Email")
</p>
<p>
@Html.Label("Subject", "Subject"): @Html.TextBox("Subject")
</p>
<p>
@Html.Label("Message", "Message"): @Html.TextArea("Message")
</p>
<p>
<input type="submit" value="Send" />
</p>
</fieldset>
<p id="confirmation" onclick="MessageConfirmation()">
Thanks!!!
</p>
}
Run Code Online (Sandbox Code Playgroud)
我们非常欢迎任何其他解决方案/想法.
提前致谢!