ajax在firefox和chrome下提交不成功的解决办法

<   inputtype="submit"   id="addBtn"   class="b_btn"   value="修改"   />

$("#addBtn").click(function(){
var serializedForm = $("#struForm").serialize();
$.post("${ctx}/resourceColumn/edit.do", serializedForm,function (result) {
              if ("suc" == result) {
                top.location.replace("${ctx}/resourceInfo/list.do?ts="+newDate().getTime()); //如果发表成功则跳到列表界面 
// 关闭弹窗窗口
      parent.dataSourceDialog.close();
              }else if ("notThroughSecurityCheck" ==result["isThroughSecurityCheck"]) {// 如果不通过安全检查
                  var mess =result["mess"];
                  $.post("${ctx}/common/notThroughSecurityCheck.do?ts="+newDate().getTime(), mess, function(res){
                      alert(res);
                  },"json");
                                 
              } else {
              alert(result);
              }
}, "json");
});

错误:在ie下提交没有问题,但是firefox或者chrome下提交就不成功,找了N多网站,终于找到原因了,
“分析下来,如果button被firefox,chrome视为submit,就可以合理解释出现的问题了. 
button的onclick事件和submit同时触发,ajax发出请求后(默认异步提交),submit事件终止了ajax的请求,因此,在chrome的开发人员工具里面可以看到这一奇怪的现象,status是cancled,type是pending(正常应该是text/html或其他)”
http://www.iteye.com/problems/88324
把input的type改成button,再尝试,一切OK。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值