0

我使用的是 jQuery 1.7.2,而 jQuery-ui 是 1.10.4。我的代码在 FireFox 中完美运行。我的 jQuery 代码如下。

$(document).ready(function () {
  $("#progressbar").show();
      $("#progressbar").progressbar({
        value: false
      });
      progress(10, "Initialize");
      /* If Season Year is zero than throw error */
      if (seasonYearCount == 0) {
        progress(0, Res.errGeneratingSchedule);
        return;
      }
      if (seasonYearMonthCount == 0) {
        $("#lbErrorMsg").text(Res.errGeneratingSchedule);
        progress(0, Res.errGeneratingSchedule);
        alert(Res.setupSeasonYearMonth);
        return;
      }
      if (productYearCount == 0) {
       progress(15, "Adding Products");
      }

      $.each(productArray, function (index, product) {
        progress(17, "Adding Complaints");
      });
      _days = daysInMonth($("#dpMonth").val(), $("#dpYear").val());
      for (var pWC = 0; pWC < _productWithComplaint.length; pWC++) {
        progress(pWC + 17, "Making Plan");
      //console.dir(_plan);
      progress(100, "Complete");
      $("#progressbar").hide();
});

function progress(value, text) {
$("#progressbar").progressbar("value", value);
var currValue = $("#progressbar").progressbar("value");

$("#lbMessage").text(text + " - " + currValue + "%");
 }

这是我的 HTML 代码

<div id="progressbar" style="display:none;">
 <div id='lbMessage'>Loading...</div>
</div>

有人可以帮忙吗...

小提琴源代码http://jsfiddle.net/milindsaraswala/2CFxZ/

4

1 回答 1

0

我怀疑这是一个语法错误。您还没有关闭 for 循环上的大括号:

      for (var pWC = 0; pWC < _productWithComplaint.length; pWC++) {
        progress(pWC + 17, "Making Plan");

      } // <== MISSING THIS

      //console.dir(_plan);
      progress(100, "Complete");
      $("#progressbar").hide();
});

始终检查控制台是否有 JS 错误。

编辑

你小提琴中的代码工作正常。它运行得如此之快,以至于您看不到从 0 到 100 的进度。您根本看不到进度条,因为您在其余代码完成后立即将其隐藏,这只需要几毫秒。

于 2014-01-27T19:17:25.923 回答