1

こんにちは、プログレスバーの表示でJQに問題があります。問題は、ページに何も表示されないことです。

これで何が悪いのか。

<script>
$(document).ready(function() {
     $("#getlist").load("toolkit/getlist.php");
   var refreshId = setInterval(function() {

var progress = setInterval(function() { var $bar = $('.bar');

    if ($bar.width()==400) {
        clearInterval(progress);
        $('.progress').removeClass('active'); } else { $bar.width($bar.width()+4); }
    var refreshId = setInterval(function() {
      $("#getlog").load('toolkit/getlog.php?randval='+ Math.random());
        $bar.text($bar.width()/4 + "%"); }, 800);

</script>

これは、進行状況を示すブートストラップからの進行状況バーです

<div class="progress">
 <div class="bar"
 style="width: ;"></div> 
 </div>  

これは、JQ getlog.php?を介してロードしている外部phpファイルであり、echo""を出力します。$progress。"%";

$content = @file_get_contents('../logs/block.txt');

if($content){
    //get duration of source
    preg_match("/Duration: (.*?), start:/", $content, $matches);

    $rawDuration = $matches[1];

    //rawDuration is in 00:00:00.00 format. This converts it to seconds.
    $ar = array_reverse(explode(":", $rawDuration));
    $duration = floatval($ar[0]);
    if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
    if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;

    //get the time in the file that is already encoded
    preg_match_all("/time=(.*?) bitrate/", $content, $matches);

    $rawTime = array_pop($matches);

    //this is needed if there is more than one match
    if (is_array($rawTime)){$rawTime = array_pop($rawTime);}

    //rawTime is in 00:00:00.00 format. This converts it to seconds.
    $ar = array_reverse(explode(":", $rawTime));
    $time = floatval($ar[0]);
    if (!empty($ar[1])) $time += intval($ar[1]) * 60;
    if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;

    //calculate the progress
    $progress = round(($time/$duration) * 100);

 echo "  " . $progress . "%" ;
4

1 に答える 1

1

答えは

<div class="progress">
<div class="bar" style="width:<?php echo $progress;?>%"></div>
    </div>
于 2012-10-26T10:52:53.217 に答える