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 ...
随机推荐
- flutter 小知识
隐藏控件,占空间 new Offstage( offstage: true, //这里控制 child: Container(color: Colors.blue,height: 100.0,), ) ...
- git clone慢的解决办法
转自:http://www.kindemh.cn/ 转自Kindem的博客 问题 大家可能都遇到过从github使用git clone指令奇慢无比的问题,网上很多人说使用代理来加速git,但是这也不是 ...
- 9. DMA
9.1 介绍 Direct memory access(DMA) 直接存储器访问. 这两个DMA控制器总共有16个流(每个控制器8个),每个流用于管理来自一个或多个外围设备的内存访问请求.每个流总共可 ...
- SPOJ MAXMATCH - Maximum Self-Matching (FFT)
题目链接:MAXMATCH - Maximum Self-Matching Description You're given a string s consisting of letters 'a', ...
- 为Python终端提供持久性历史记录
有没有办法告诉交互式Python shell在会话之间保留其执行命令的历史记录? 当会话正在运行时,在执行命令之后,我可以向上箭头并访问所述命令,我只是想知道是否有某种方法可以保存这些命令,直到下次我 ...
- hdu6354 /// 线段树
题目大意: 给定n m x y z 长度为n的序列初始为0 接下来m个操作 l r v 将l r区间内比v小的数都变成v l r v由x y z和给定的函数生成 线段树维护区间 最大值 最小值 再加 ...
- echart 柱状图背景色设置
方法一: series: [ { name: '1', type: 'bar', itemStyle: {//柱图背景色 color: '#111' }, data: list }, { name: ...
- 解决MSF更新证书错误
如下图所示提示签名无效下载失败,导致更新不了msf 解决办法如下: echo 'deb http://apt.metasploit.com/ lucid main' > /etc/apt/sou ...
- jdk源码阅读-ConcurrentLinkedQueue(一)
说明 concurrentLinkedQueue为无界非阻塞队列,是线程安全的 内部结构为链表的形式, 内部使用cas保存线程安全.采用cas保证原子性 什么是CAS CAS 操作包含三个操作数 —— ...
- 深度探索C++对象模型读书笔记-第六章执行期语意学
在函数中,编译器会帮助将析构函数(Destructor) 安插在相应的位置.对于函数中的局部对象,会将析构函数安插在对象的每一个离开点. 例如: 1: void Function(int a) { 2 ...