[英]jquery/javascript: how to load (some) images sequentially rather than in parallel?
The problem is unique to Single Sign On sites with cross site links. 该问题是具有跨站点链接的单一登录站点所独有的。 The portal (my project) maintains a database of metadata describing images on two remote sites.
门户(我的项目)维护着一个描述两个远程站点上图像的元数据数据库。 All 3 require Shibboleth authentication and use the same identity provider.
所有3个都需要Shibboleth身份验证并使用相同的身份提供者。
When users connect to machine that does not have an existing session they are redirected to the Identity Provider, if they have a session there info a back channel is used to create a local session. 当用户连接到没有现有会话的计算机时,他们将被重定向到身份提供者,如果他们有会话,则使用后向通道创建本地会话的信息。
The problem occurs when a browser opens multiple simultaneous connections that need to create a new local session. 当浏览器打开多个同时需要创建新的本地会话的连接时,就会发生此问题。 One connection might succeed but most if not all will fail.
一个连接可能会成功,但大多数(如果不是全部)都将失败。
The solution (I think) is to have a small image from each remote site on the first portal page that are loaded one at a time. 解决方案(我认为)是在第一个门户网站页面上的每个远程站点上都有一个小的图像,每次加载一个。 Once the sessions are established everything works well.
建立会话后,一切都会正常进行。
Finally my question: how do I load a list of remote images one at a time waiting for each to fully load before requesting the next one. 最后,我的问题是:如何在请求下一个远程映像之前一次加载一个完整的远程映像列表。
var imageNames = ['img1.png', 'img2.png'];
var counter=0;
function loadImage(imageName, counter){
$.get(imageName).done(
function(){
console.log(imageNames[counter] + ' loaded');
counter++;
if(counter < imageNames.length){
loadImage(imageNames[counter], counter);
}
}
);
}
loadImage(imageNames[counter], counter);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.