【问题标题】:Can we stop sending ajax for a while and continue?我们可以暂时停止发送ajax并继续吗?
【发布时间】:2015-06-04 13:34:58
【问题描述】:

我需要在 OnBegin 上停止发送 Ajax.ActionLink 的 ajax 请求一段时间,如果确认警报为真,则 继续 请求.在下面的代码中,我可以中止 ajax 请求,有没有办法使用自己的方法重新发送它。

beforeDelete: function (x, y) {
    x.abort();
    bootbox.confirm("Are you sure you want to delete this?", function (result) {
        if (result) { 
          //process again
        }
    });
}

编辑: 我已经实现了,谢谢 Guruprasad。

var prevDel = true;
function beforeDelete(x, y) {
    if (prevDel) {
        x.abort();
        bootbox.confirm("Are you sure you want to delete this?", function (result) {
            if (result) {
                prevDel = false;
                $.ajax(y);
            } else {
                prevDel = true;
            }
        });
    } else {
        prevDel = true;
    }
}

【问题讨论】:

标签: asp.net-mvc alert actionlink bootbox unobtrusive-ajax


【解决方案1】:

好的...你可以分解代码:

bootbox.confirm("Are you sure you want to delete this?", function (result) {
        if (result) { 
          //send ajax request from here
        }
    });

【讨论】:

  • 我正在寻找像 abort() 这样的方法来重新发送请求。我已经知道要编写新的 ajax 代码
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-12
  • 1970-01-01
  • 2012-08-30
相关资源
最近更新 更多