当前位置:  开发笔记 > 编程语言 > 正文

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

如何解决《提交的Ajax复选框可以防止点击发布/提交》经验,为你挑选了1个好方法。



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);
                }
          });
});

推荐阅读
135369一生真爱_890
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有