照片擦拭相同的源代码,但输出不起作用 [英] Photoswipe same source code but output not working

查看:104
本文介绍了照片擦拭相同的源代码,但输出不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码,它刷新了ul的内容.

I have this piece of code, which refreshes the content of an ul.

它可以在第一次加载时工作,在这里直接加载ul的内容,但是我每10秒制作一次新内容,以便用户始终可以获取新内容.

It works on the first load, where the content of ul is directly loaded, but i am making new content every 10 seconds so that user can always get new content.

由javascript调用传递的内容的源代码与第一次加载完全相同.然后javascript调用也不起作用

The source code of content delivered by javascript call is exactly same as the first load. Then also javascript call does not work

JavaScript:

The Javascript:

<script type="text/javascript">
    setInterval(function() {
        $("#vbar").load(location.href+" #vbar>*","");
    }, 10000);
</script>

html代码为:

<ul  id="vbar" class="gallery">           
    <li>
        <a href="http://i2.listal.com/image/3550836/600full-taylor-swift.jpg" rel="external">Taylor Swift  </a>
    </li>
    <li>
        <a href="http://i2.listal.com/image/303530/600full-jessica-lange.jpg" rel="external">Jessica Lange  </a>
    </li>
    <li>
        <a href="http://i2.listal.com/image/2844304/600full.jpg" rel="external">  </a>
    </li>
    <li>
        <a href="http://i2.listal.com/image/524086/600full-caroline-ribeiro.jpg" rel="external">Caroline Ribeiro  </a>
    </li>
    <li>
        <a href="http://i2.listal.com/image/2402821/600full-francine-dee.jpg" rel="external">Francine Dee  </a>
    </li>                
</ul>

我尝试不使用缓存,并且在标头中使用了此代码,然后也没有使用

I have tried no cache and used this code in header then also no use

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />

此处有实时代码

    http://www.way2enjoy.com/touch/w2et/newphoto12.php

此外,插入新内容时,我可以更改网址

in addition to that can i change the urlwhen new content are inserted

推荐答案

我会使用 jQuery就绪.

类似

<script type="text/javascript">
$(document).ready(function(){
    setInterval(function() {
        $("#vbar").load(location.href+" #vbar>*","");
    }, 10000);
});
</script>

但是, @Cletus在他的回答中解释了一种更好的方法.

示例中有一个轮播,您在评论中链接了部分,现在的问题是,在轮播中,setTimeout不会更新轮播

There is a carousel in the example that you linked in the comment section, the issue right now is that while in the carousel, the setTimeout doesn't update the carousel

解决方案:

  • 创建一个数组来存储所有正在更新的图像.
  • 更新轮播中的img,在setTimeout中调用轮播

在这两者中,您都需要查看轮播中的代码是否阻止了超时代码.使用chrome开发工具进行检查,甚至使用 alert('test'); 都可以完成这项工作.

In both, you need to see if the code in the carousel is blocking the code of the timeout. Check with chrome dev tools, or even an alert('test'); should do the job.

这篇关于照片擦拭相同的源代码,但输出不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆