Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 计算图像加载进度不工作_Php_Jquery Ui_Jquery_Jquery Mobile - Fatal编程技术网

Php 计算图像加载进度不工作

Php 计算图像加载进度不工作,php,jquery-ui,jquery,jquery-mobile,Php,Jquery Ui,Jquery,Jquery Mobile,我试图显示一个进度条,同时加载一个大的图像,它加载了多少,但根据我所有的谷歌搜索和在这里,我还没有找到我要找的 我能够添加加载GIF,直到加载GIF,然后使用 $('img').load(function() { // my code here } 我还使用了: $(function() { $( "#progressbar" ).progressbar({ value: 37 }); }) 但我不知道如何计算使用javascript或jque

我试图显示一个进度条,同时加载一个大的图像,它加载了多少,但根据我所有的谷歌搜索和在这里,我还没有找到我要找的

我能够添加加载GIF,直到加载GIF,然后使用

$('img').load(function() {
    // my code here
}
我还使用了:

 $(function() {
     $( "#progressbar" ).progressbar({
        value: 37
     });
 })
但我不知道如何计算使用javascript或jquery加载的单个图像的百分比


非常感谢各位提供的任何帮助

您可以这样做,加载图像以及图像并显示进度:

$.each(arrayOfImageUrls, function(index, value) {
    $('<img></img>').attr('src', value)    //load image
        .load(function() {
            percentCounter = (index / arrayOfImageUrls.length) * 100;    //set the percentCounter after this image has loaded
            $('#yourProgressContainer').text(percentCounter + '%');
        });
});
$。每个(arrayOfImageUrls、函数(索引、值){

$('您可以先发送一个较短的请求并计时。例如,您知道在不久的将来您将需要一个100kb的映像;因此,在不缓存的情况下加载它,并测量接收所需的时间。然后通过一些简单的数学计算,您可以估计另一个映像需要多长时间,并且有一个粗略的进度条(总比没有好)。另一个选项可能是web套接字。