当前位置:   jquery > 正文

提交的Ajax复选框可以防止点击发布/提交

javascript,ajax,checkbox,jquery,go,DevBox,在线流程图,编程,编程问答,程序员,开发者工具,开发工具,json解析,二维码生成,unix时间戳,在线开发工具,前端开发工具,开发人员工具,站长工具



1> Shyju..:

您可以在启动ajax调用之前禁用该复选框.您可以使用该prop()方法来执行此操作.将disabled属性值设置为true

$(".chkOverride").click(function (e) {

      var _this=$(this);
      _this.prop('disabled', true);

      var userId = $("#UserId").val();
      var isChecked = $(this).is(":checked")
      $.ajax({
                url: "/Worker/Worker?Id=" + Id + "&isChecked=" + 
                                                       isChecked + "&UserId=" + UserId,
                type: "post",
                success: function (result) {
                    alert("Success!");
                   //No point in enabling as you are going to reload the page
                   _this.prop('disabled', false);
                    location.reload();

                },
                error: function () {
                  alert("Error :(");
                   _this.prop('disabled', false);
                }
          });
});

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/jquery/detail/13652
推荐阅读
相关标签
  

闽ICP备14008679号