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