您好,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 " " 。$进度。"%" ;
$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 . "%" ;