Javascript-how to load more data to a scroll bar in a mobile web Site

Source: Internet
Author: User
Good afternoon, ladies and gentlemen. I want to add more data functions to my mobile website and slide down the Sina Weibo APP scroll bar. How can I implement this function? Could you please give me some advice, if you have any good code, I would like to thank you very much for your good afternoon. I want to add more data functions to my mobile website by sliding down the APP scroll bar of Sina Weibo, how can this function be implemented? Could you please give me some advice and share some good code? Thank you very much

Reply content:

Good afternoon, ladies and gentlemen. I want to add more data functions to my mobile website and slide down the Sina Weibo APP scroll bar. How can I implement this function? Could you please give me some advice, thank you very much for sharing any good code.

This mode is called Infinite Scroll. Various frameworks and class libraries have mature implementations. For more information, see

The idea is very simple (in fact, the implementation is also very simple), that is, ajax background request data is inserted to the end of the document. It doesn't matter if the html string that you rendered in the background is the data provided in the backend and then Javascript is rendered.

$. Ajax ({.... // slightly success: function (data) {$ ('body '). append (data) // Meaning },...})

You can monitor the event of the scroll bar and start loading at PX from the bottom.

    $(window).scroll(function() {        if ($(document).scrollTop() + $(window).height() > $(document).height() - 100) {            $.get(url, function(data) {                $('#list').append(data);            });        }    });

Listen to rolling events and load more images in the callback function

With iScroll. js and ajax request data, you can pull up and load the data, pull down and refresh it. You can try it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.