MVC3下使用Jquery异步提交数据!

效果:

JS提交表单代码:

<script type="text/javascript">
function submitForm() {
$.ajax({
type: 'POST',
url: '@Url.Action("AJAXReview", "Common")',
data: $("#form1").serialize(),
success: function (data) {
if (data.res)
alert("提交成功");
else
alert("提交失败,失败信息为:" + data.info);
}
})
}
</script>

 

 

View:

@using (Html.BeginForm("Review", "Common", FormMethod.Post, new
{
id = "form1"
}))
{
<fieldset>
<legend>评论 </legend>
<ul>@Html.ValidationSummary(true)
@Html.HiddenFor(i => i.ObjID)
@Html.HiddenFor(i => i.ObjType)
<li></li>
<li>标题:@Html.TextBoxFor(i => i.Title)</li>
<li>@Html.ValidationMessageFor(i => i.Title)</li>
<li>内容:@Html.TextAreaFor(i => i.Content)</li>
<li>@Html.ValidationMessageFor(i => i.Content)</li>
</ul>
</fieldset>
<input type="button" onclick="submitForm()" value="提交" />
}

 

 

 

posted on 2013-04-08 09:07  米高佐敦  阅读(231)  评论(0编辑  收藏  举报