日期:2014-05-18 浏览次数:20499 次
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MvcApplication.Models.UserInfo>" %> <% using (Html.BeginForm()) {%> 用户名:<%:Html.TextBoxFor(model => model.UserName)%> 密码:<%:Html.TextBoxFor(model => model.UsePwd)%> <input type="Submit" value="添加"> <%}%>
/// <summary> /// 添加 /// </summary> /// <returns></returns> [HttpPost] public ActionResult Create(UserInfo userinfo) { //这怎么写?怎么知道我添加成功失败? }
$('#form名称').ajaxSubmit(function (data) {});
------解决方案--------------------
$(function () { $("#formname").validate({ submitHandler: function (form) { $(form).ajaxSubmit({ clearForm: false, success: function (responseText, statusText, xhr, $form) { if (responseText.OK) { alert(responseText.Message); window.location.href = '@Url.Action("Index")'; } else { alert(responseText.Message); } } }); } }); });
------解决方案--------------------
$('#form名称').ajaxSubmit(function (data) { if(data=="ok"){ }else{ } });
------解决方案--------------------