【问题标题】:bootbox confirm before ajax callajax 调用前的 bootbox 确认
【发布时间】:2014-09-15 11:43:20
【问题描述】:

我有这个 Javascript 代码:

this.confirmBox = function(event, data) {
  return bootbox.confirm("Are you sure?", function(result) {
    alert(result); // this returns TRUE as it is supposed to
  });
};

this.beforeSend = function(event, jqXHR) {
  if (this.confirmBox()) {
    // HERE THE AJAX QUERY GETS EXECUTED
  } else {
    return jqXHR.abort(); // HERE WE ABORT IT
  }
};

我的问题是 ajax 查询在我在 bootbox 弹出窗口中确认之前被执行。我如何需要更改(this.confirmBox()) 行,以便让 beforeSend 函数检查 confirmBox 函数是否返回 true?

【问题讨论】:

    标签: javascript ajax bootbox


    【解决方案1】:

    你需要把this.beforeSend放在确认框的function(result)....里面

    【讨论】:

    • 不起作用。一旦 bootbox 异步加载,ajax 调用仍然会进行。
    • 请用新代码修改原来的问题,这样我就可以看到你写的和不工作的地方
    • 问题是即使我完全删除了 beforeSend 函数,ajax 请求也会被执行。原始脚本使用的是 natve confirm popop,它会阻止 ajax 在确认之前执行。使用我现在尝试的任何插件(bootbox、jconfirm 和 jquery.msg)我都无法获得相同的结果。
    猜你喜欢
    • 1970-01-01
    • 2016-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-14
    • 2012-05-19
    • 1970-01-01
    相关资源
    最近更新 更多