我在IE9中看到以下内容
提交发生在一个函数内部,该函数通过setTimeout递归调用自身,我认为这可能是罪魁祸首。但从逻辑上讲,我认为提交可能会发生两次。这是功能:
function callback() {
"use strict";
var poll_timeout, // setting a var in case we need to kill the timeout mid count
poll_counter = 0, // start a counter
max_polls = 10; // set a max count
function doPoll() {
if (poll_counter < max_polls) { // make sure we're not above the count
poll_counter++; // increment the counter
$.post("/someUrl", function (success) {
// ajax it
if (success) {
$("form#checkout").off('submit', Store.cancel_submit)
$('form#checkout').submit();
} else {
// do it again
poll_timeout = setTimeout(doPoll,10000);
}
});
}
}
doPoll();
}
答案 0 :(得分:0)
我不熟悉jQuery的$.post
,如果它与$.ajax
不一样,但我会这样做是为了防止poll_timeout在我们成功时再次运行:
if (success) {
clearTimeout(poll_timeout);
$("form#checkout").off('submit', Store.cancel_submit)
$('form#checkout').submit();
} else {
// do it again
poll_timeout = setTimeout(doPoll,10000);
}