Re: [問題] 延後執行的問題
無任何套件的情況下可以用setTimeout檢查
function checkAndDoSomething() {
if (array.length === m.length) {
//do some thing
}
else {
setTimeout(checkAndDoSomething, 100);
}
}
setTimeout(checkAndDoSomething, 100);
有使用套件的情況下可以用jQuery的Deferred物件(比較泛用)
或async這個套件(比較專用適用)處理
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.164.58.28
※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1440201400.A.089.html
→
08/22 23:11, , 1F
08/22 23:11, 1F
→
08/22 23:11, , 2F
08/22 23:11, 2F
推
09/20 01:02, , 3F
09/20 01:02, 3F
討論串 (同標題文章)
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章