Javascript-js How to limit the number of slides to load when sliding load

Source: Internet
Author: User
User on the slide load more time, because of the speed or the server returned data is slow, how to limit the slide to load only once paging data, how to implement the code

Reply content:

User on the slide load more time, because of the speed or the server returned data is slow, how to limit the slide to load only once paging data, how to implement the code

Then request the data to be returned successfully and render to the page and then add 1 pages

This is also the basic need to prevent duplicate submissions.
You set a variable as a state lock, such as is_post = 0 pull-up request data 1, at this time pull no longer make a request, and so a request data completely back, and then set 0 on the line.

You need to throttle/debounce . Searched an article for you: Http://www.css88.com/archives ...

Depending on your situation, Lodash/underscore has a ready-made method to use.

Stand a flag, haha.

As an example,

var loading = false;nextPage(1);function nextPage(page) {  if (loading) return;  loading = true;  $.ajax({    // ....    success: function() {      loading = false;    }  })}

One is a state lock, as the upstairs says

There's another one called JS function throttling, go search

  • Related Article

    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.