我可以done()
在“非 ajax”函数上使用 jquery。Uncaught TypeError: Cannot call method 'done' of undefined
当我尝试做这样的事情时,我得到了错误。
function countThreeSeconds() {
var counter = 0,
timer = setInterval(function () {
if (counter == 3) {
console.log("All done. That was three seconds.");
window.clearInterval(timer);
} else {
console.log("Not there yet. Counter at: " + counter);
}
counter++;
}, 1000);
}
(function(){
var timer = countThreeSeconds().done(function(){
alert("done");
});
}());
谢谢