phdphd Posted September 6, 2013 Share Posted September 6, 2013 Hi All,On my webpage I have a div that scrolls vertically, with a list of items in it. The items in the div come from a php array. I noticed that the building of the div gets slow when there are many items in the array. Since the user might not be interested by the contents of the div, I am considering filling the div by only adding items to it each time the user scrolls down to the end of the div. So basically, each time the user would reach the bottom of the div, the JS code would add items from the php array to the list in the div. Is it possible to implement this ?Thanks. Link to comment https://forums.phpfreaks.com/topic/281944-adding-items-to-a-div-each-time-the-users-scrolls-down-to-the-end-of-the-div/ Share on other sites More sharing options...
kicken Posted September 7, 2013 Share Posted September 7, 2013 Yes, you would listen for the scroll event, and check what position they are scrolled to. If they have reached the bottom, send an ajax request to get more items then add them to the div. If you're using jQuery it will simplify the job significantly compared to using the raw api's I linked above. Link to comment https://forums.phpfreaks.com/topic/281944-adding-items-to-a-div-each-time-the-users-scrolls-down-to-the-end-of-the-div/#findComment-1448619 Share on other sites More sharing options...
phdphd Posted September 10, 2013 Author Share Posted September 10, 2013 thanks for the info. Link to comment https://forums.phpfreaks.com/topic/281944-adding-items-to-a-div-each-time-the-users-scrolls-down-to-the-end-of-the-div/#findComment-1448981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.