Ajax.BeginForm 在 Chrome下的问题
项目背景:MVC4
代码:
@using (Ajax.BeginForm("Index", "GoingMeter", new AjaxOptions { OnSuccess = "result",OnBegin="begin" }))
{
// do something......
}
.....
function result(e)
{
//....
}
function begin()
{
alert('提交了。。。');
}
在用Google Chrome、Safari时,result、beign 一直没执行,而在IE、Mozilla Firefox却正常。
最后在stackoverflow找到了答案:
I have found a weird solution to the problem. I was calling the ajax form's submit through an 'a' tag like so:
<A href='#' onclick="javascript:$('#ajaxform').submit();">Remove</a>
For some reason calling the '.submit()' from an 'a' tag was messing up in chrome causing a full page refresh instead of an ajax call. I fixed the issue by using the following code instead:
<input type='submit' value='Remove' />
This solution also worked when I needed to add javascript commands to the input to ask for confirmation before deleting. The only gripe is that I needed to swap around some markup to ensure that my buttons were happening within the form that they were submitting (something that I understand isn't always possible in all situations).
把<a href="#" onclick="$("form").submit();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'" id="btnSave">保存</a>
改成 <input type="submit" value="保存"/>就一切OK了。
来自:http://guolingfa.cn/Article/Details/b342c20102874b75971126fa1bdb8a75
Ajax.BeginForm 在 Chrome下的问题的更多相关文章
- jQuery ajax方法在Chrome浏览器下失效问题
最近做测试时碰到一个问题,chrome下使用ajax的一些方法(如get,load等)的时候完全失效: $(function() { $("#send").click(functi ...
- ASP.NET MVC下Ajax.BeginForm方式无刷新提交表单
有时候,不得不考虑到以下场景问题: 数据库表字段会频繁更改扩展,而流行的重业务的js框架过于依赖json数据接口,导致的问题是,数据库表更改 -> 数据接口更改 -> 前段框架逻辑更改.. ...
- Ajax.BeginForm方法 参数
感谢博主 http://www.cnblogs.com/zzgblog/p/5454019.html toyoung 在Asp.Net的MVC中的语法,在Razor页面中使用,替代JQuery的Aja ...
- Ajax.BeginForm VS Html.BeginForm
有的人说,AJAX一听,高大上,HTML一听,死老土,所以AJAX更好.其实这是错误的.每种方法有它不同的用途.现在做如下总结: @using (Ajax.BeginForm("Login& ...
- Ajax.BeginForm参数详解
在Asp.Net的MVC中的语法,在Razor页面中使用,替代JQuery的Ajax使用,方便快捷. 使用Ajax.BeginForm方法会生成一个form表单,最后以Ajax的方式提交表单数据:需要 ...
- 爱上MVC3系列~Html.BeginForm与Ajax.BeginForm
Html.BeginForm与Ajax.BeginForm都是MVC架构中的表单元素,它们从字面上可以看到区别,即Html.BeginForm是普通的表单提交,而Ajax.BeginForm是支持异步 ...
- form表单和ajax表单提交(Html.BeginForm()、Ajax.BeginForm())的差别
有如下几种区别: 1. Ajax在提交.请求.接收时,都是异步进行的,网页不需要刷新: Form提交则是新建一个页面,哪怕是提交给自己本身的页面,也是需要刷新的: 2. A在提交时,是在后台新建一个请 ...
- Html.BeginForm())与Ajax.BeginForm()
一.@using (Html.BeginForm())参数示例 1.指定表单提交方式和路径等 @using (Html.BeginForm("Index", "Home ...
- Ajax.ActionLink与Ajax.BeginForm使用场所的思考
Ajax.ActionLink使用在提交参数明确的情况下,如: Ajax.ActionLink("加入购物车", "AddToCart", "Cart ...
随机推荐
- 17、通过maven生成测试报告
目录如下: 通过Maven 生成报告 进入testngTest根目录,运行mvn test 命令 进入 testngTest\target\surefire-reports 路径查看测试报告
- Linux内核代码布局
上文参考:http://www.cnblogs.com/long123king/p/3545991.html 先分析一下linker script的语法. #ifdef CONFIG_X86_32#d ...
- pymongo中使用聚合查询
在使用mongo数据库时,简单的查询基本上可以满足大多数的业务场景,但是试想一下,如果要统计某一荐在指定的数据中出现了多少次该怎么查询呢?笨的方法是使用find 将数据查询出来,再使用count() ...
- ThinkPHP5验证码不显示的原因及解决方法
其实很久之前刚学习tp5框架的时候就遇到了这个问题,解决完后一直没再出过问题,今天用以前的框架做新项目时又碰到了这个问题,这里记录一下 问题原因: 1.TP5本就存在这个bug 2.数据库连接不正常( ...
- Java中有趣的String、StringBuffer与StringBuilder
String介绍 String类属于java.lang包中,String类是不可变类,任何对String的改变都会引发新的String对象的生成. 创建String的两种方式: 1.通过构造器创建:S ...
- 不走弯路,微信小程序的快速入门?
微信小程序下载注册地址:https://mp.weixin.qq.com/cgi-bin/wx 微信小程序登开发者平台地址(可以查看小程序APPID):https://mp.weixin.qq.com ...
- D3.js 动画 过渡效果 (V3版本)
一 . 过渡的启动 启动过渡效果,与以下四个方法相关: d3.transition([selection],[name]) //创建一个过渡对象.但是由于每个选择集中都有transition( ...
- codeforces750E New Year and Old Subsequence 矩阵dp + 线段树
题目传送门 思路: 先看一个大牛的题解 题解里面对矩阵的构造已经写的很清楚了,其实就是因为在每个字符串都有固定的很多中状态,刚好可以用矩阵来表达,所以$(i,j)$这种状态可以通过两个相邻的矩阵的$m ...
- 使用自己的Python函数处理Protobuf中的字符串编码
我目前所在的项目是一个老项目,里面的字符串编码有点乱,数据库中有些是GB2312,有些是UTF8:代码中有些是GBK,有些是UTF8,代码中转来转去,经常是不太清楚当前这个字符串是什么编码,由于是老项 ...
- 修改Tomcat的端口号方法
(1).查找conf路径下的server.xml文件,路径如: I: \tomcat6\apache-tomcat-6.0.32\conf\server.xml (2).打开server.xml文 ...