CSSを使用して作成されたこのAJAXローダーがあります。
そして、ユーザーが進行状況を確認できるように、表示される負荷の割合を 1 秒ごとに 10% ずつ増加させようとしています。
このsetTimeout
関数を使用して、1 秒ごとに呼び出しています。
関数とFiddleは次のとおりです。
$(document).ready(function() {
var increase = 10;
setTimeout(function() {
increase = increase + 10;
$("#result").html("<div class='progress progress-striped active' style='width :300px; margin:0 auto;'><div class='bar' style='width: " + increase + "%;'></div></div>");
if (increase == 100) {
increase = 10;
}
}, 1000);
});