The example in this article describes how jQuery implements dynamic loading of content when the page is scrolled. Share it with everyone for your reference. The specific analysis is as follows:
Many websites, such as twitter and JD.com homepage, will dynamically load the page content when the page scrolls to a certain position. This can speed up the opening of the page and save bandwidth. The following JS code can help you do it. arrive.
var loading = false; $(window).scroll(function(){ if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){ if(loading == false){ loading = true; $('#loadingbar').css("display","block"); $.get("load.php?start="+$('#loaded_max').val(), function(loaded){ $('body').append(loaded); $('#loaded_max').val(parseInt($('#loaded_max').val())+50); $('#loadingbar').css("display","none"); loading = false; }); } } }); $(document).ready(function() { $('#loaded_max').val(50); });
I hope this article will be helpful to everyone’s jQuery programming.