在填充文件夹时,使用jquery / bootsrap显示文件夹中的图像

时间:2022-08-09 00:30:25

I am very very new to UI. So this question might look like a repeated one, but I frankly couldn't find an answer to this.

我对UI非常陌生。所以这个问题可能看起来像是重复的问题,但坦率地说,我找不到答案。

My application is running a background thread which downloads some images and stores it in a folder say images . I need to display these images in UI as and when the images are getting populated in folder. How should I proceed? I am using jQuery and Twitter bootstrap framework.

我的应用程序正在运行一个后台线程,它下载一些图像并将其存储在一个文件夹中。当图像被填充到文件夹中时,我需要在UI中显示这些图像。我该怎么办?我正在使用jQuery和Twitter bootstrap框架。

Any help will be appreciated.

任何帮助将不胜感激。

Thanks in advance :)

提前致谢 :)

1 个解决方案

#1


0  

This code will check if there are present image .png in a directory and if there are it will show they. Modify it for your purpose. To check when the folder is getting populated you can use a function timer for this code. There are two options, you can use delay() of jquery, or setTimeout() of basic javascript.

此代码将检查目录中是否存在当前图像.png,如果有,则会显示它们。根据您的目的修改它。要检查文件夹的填充时间,可以使用此代码的函数计时器。有两个选项,你可以使用jquery的delay()或基本javascript的setTimeout()。

var dir = "Src/themes/base/images/";
var fileextension = ".png";
$.ajax({
    //This will retrieve the contents of the folder if the folder is configured as 'browsable'
    url: dir,
    success: function (data) {
        //List all .png file names in the page
        $(data).find("a:contains(" + fileextension + ")").each(function () {
            var filename = this.href.replace(window.location.host, "").replace("http://", "");
            $("body").append("<img src='" + dir + filename + "'>");
        });
    }
});

#1


0  

This code will check if there are present image .png in a directory and if there are it will show they. Modify it for your purpose. To check when the folder is getting populated you can use a function timer for this code. There are two options, you can use delay() of jquery, or setTimeout() of basic javascript.

此代码将检查目录中是否存在当前图像.png,如果有,则会显示它们。根据您的目的修改它。要检查文件夹的填充时间,可以使用此代码的函数计时器。有两个选项,你可以使用jquery的delay()或基本javascript的setTimeout()。

var dir = "Src/themes/base/images/";
var fileextension = ".png";
$.ajax({
    //This will retrieve the contents of the folder if the folder is configured as 'browsable'
    url: dir,
    success: function (data) {
        //List all .png file names in the page
        $(data).find("a:contains(" + fileextension + ")").each(function () {
            var filename = this.href.replace(window.location.host, "").replace("http://", "");
            $("body").append("<img src='" + dir + filename + "'>");
        });
    }
});