简体   繁体   中英

random infinite scrolling from data

I'm making a site that will show an endless series of images. The random list of images would be produced by a php script reading urls from a .txt. In the client side I need to show this images in different divs with random size and position. The question is: I had to produce a list that I insert in the rendered html that the JS could take? any direction for this JS that reads the urls and creates divs on the fly with random width/margins while scrolling?

excuse the noobness. and thanks a lot for any help.

The PHP script will execute ONCE at the loading of the website, so unless you're using ajax calls or something, you can't just output an "infinite" amount of data with PHP because you will sooner or later timeout.

You should use jQuery and learn how to use $.ajax to call the php to load more images using jQuery append. That should be an easy and clean way to do it (calling the event everytime the user reach the bottom of the website.

You can use some kind of infinite loading library like masonry . Here is the example demo here . It's help material can be seen here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM