1、确定unobtrusive-ajax已经引用,VS2012带,2013不带

2、注意jq和unobtrusive-ajax引用顺序问题,确保jq在前

3、注意JQ和unobtrusive-ajax版本问题

1.8以上的JQ要去nuget上下载较新的unobtrusive-ajax,1.8以下的用VS2012自带的即可,2013不带,

4、如果控制台提示TypeError: $(...).live is not a function

说明JQ版本过低,JQ1.9更新了很多东西,其中live就被去掉了

引用:

<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

ajax:

            @using (Ajax.BeginForm("EditeArticleType", "UArticleType", new { }, new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterEdit" }, new { id = "addForm" }))
{
<div class="modal-body">
<div class="form-group">
<label for="recipient-name" class="control-label">分类名称:</label>
<input name="TypeName" type="text" class="form-control" id="type-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">排序:</label>
<input name="ListIndex" type="text" class="form-control" id="type-index">
</div>
<div class="form-group">
<label for="message-text" class="control-label">描述:</label>
<textarea class="form-control" id="type-describe"></textarea>
</div> </div> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary">确定</button>
</div>
}

回调函数jq:

    function afterEdit(data) {
if (data.State == 200) {
location.reload();
}
}

controller:

        [HttpPost]
public ActionResult EditeArticleType(ArticleType articleType)
{
articleTypeService = new BLL.ArticleTypeService();
if (!string.IsNullOrEmpty(articleType.TypeName))
{
articleType.MemberID = CurrentMember.ID;
articleType.IsDel = ;
articleType.CreateTime = DateTime.Now;
var newType = articleTypeService.AddEntity(articleType);
if (newType != null)
{
return Json (new ViewMessage {State=,Msg="成功",Data=null});//RedirectToAction("UArticleType", "UserCenter");
}
else
{
return View("/Views/Shared/Error.cshtml");
}
}
else
{
ViewBag.msg = "请求参数有误";
return View("/Views/Shared/Error.cshtml");
}
}

MVC中自带的异步((Ajax.BeginForm)无效的更多相关文章

  1. MVC中,查询以异步呈现,分页不用异步的解决方案

    MVC中,查询以异步呈现,分页不用异步的解决方案 这种需求,用一个ASPX页面和一个ASCX分部视图就可以解决了,ASPX提供对ASCX的引用,ASCX显示列表信息,ASPX主页面提供查询功能 < ...

  2. MVC中实现部分内容异步加载

    MVC中实现部分内容异步加载 action中定义一个得到结果集的方法 public ActionResult GetItemTree(string title, int itemid, int? pa ...

  3. .net mvc中的表单异步提交

    // // 摘要: // 将 <form> 开始标记写入响应. // // 参数: // ajaxHelper: // AJAX 帮助器. // // actionName: // 将处理 ...

  4. 微软自带的异步Ajax请求

    一.使用步骤 二.示例代码 using System; using System.Collections.Generic; using System.Linq; using System.Web; u ...

  5. ASP.NET MVC 中使用 jQuery 实现异步搜索功能

    常见的几种异步请求方式: Ajax.BeginForm   异步提交文本的形式 Ajax.ActionLinkk 文本链接的形式 Client Validataion  客户端的认证 一.用jQuer ...

  6. MVC中Spring.net 对基类控制器无效 过滤器控制器无效

    比如现在我又一个BaseController作为基类控制器,用于过滤权限.登录判断等作用,其它控制由原本的继承Controller,改为继承BaseController.然后BaseControlle ...

  7. MVC之Ajax.BeginForm使用详解之更新列表 mvc验证jquery.unobtrusive-ajax

    MVC之Ajax.BeginForm使用详解之更新列表   1.首先,请在配置文件设置如下:(该项默认都存在且为true) <add key="UnobtrusiveJavaScrip ...

  8. ASP.NET MVC中使用异步控制器

    线程池 一直想把项目改写成异步,但是ASP.NETMVC3下写的过于繁琐,.NET 4.5与ASP.NET MVC下代码写起来就比较简单了, MS好像也一直喜欢这样搞,每一个成熟的东西,都要演变好几个 ...

  9. 在 ASP.NET MVC 中使用异步控制器

    线程池 一直想把项目改写成异步,但是ASP.NETMVC3下写的过于繁琐,.NET 4.5与ASP.NET MVC下代码写起来就比较简单了, MS好像也一直喜欢这样搞,每一个成熟的东西,都要演变好几个 ...

随机推荐

  1. iis 7.0 asp.net发布问题

    问题1: 配置错误:不能在此路径中使用此配置节.如果在父级别上锁定了该节,便会出现这种情况.锁定是默认设置的………… 解决方案: 因为 IIS 7 采用了更安全的 web.config 管理机制,默认 ...

  2. C语言全局变量那些事儿

    转自:http://blog.csdn.net/bingqingsuimeng/article/details/9405743 作为一名程序员,如果说沉迷一门编程语言算作一种乐趣的话,那么与此同时反过 ...

  3. 浅谈HTTP事务的一个过程

    一个腾讯在职的朋友问道,当我们在浏览器的地址栏输入 www.baidu.com ,然后回车,这一瞬间页面发生了什么?下面以谷歌浏览器一一解释. 一.域名解析 首先Chrome浏览器会解析www.bai ...

  4. notepad++ 中配置 python一键运行

    cmd /k python "$(FULL_CURRENT_PATH)"& PAUSE & EXIT cmd /k python 表示打开Command Promp ...

  5. BestCoder 2nd Anniversary

    A题 Oracle http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=703&pid=1001 大数相加: ...

  6. oracle 资源学习汇总

    1:修改密码   http://blog.csdn.net/qh_java/article/details/23202259 2:Oracle数据库.实例.用户.表空间.表之间的关系

  7. iOS 图形图像动画 Core Animation

    //Core Animation #define WeakSelf __weak __typeof(self) weakSelf = self #define StrongSelf __strong ...

  8. Apple Pay--iOS开发

    一.什么是Apple Pay? 1. 概念 Apple Pay,简单来说, 就是一种移动支付方式.通过Touch ID/ Passcode,用户可使用存储在iPhone 6, 6p等设备上的信用卡和借 ...

  9. Theano:LSTM源码解析

    最难读的Theano代码 这份LSTM代码的作者,感觉和前面Tutorial代码作者不是同一个人.对于Theano.Python的手法使用得非常娴熟. 尤其是在两重并行设计上: ①LSTM各个门之间并 ...

  10. requirejs:模块加载(require)及定义(define)时的路径小结

    原文地址:http://www.tuicool.com/articles/7JBnmy 接触过requirejs的童鞋可能都知道,无论是通过define来定义模块,还是通过require来加载模块,模 ...