I’m using jQuery, and I already have a table set up with a specific height, with overflow:scroll. I’m wondering what I should access in order to know when to load more data from the server (I don’t need help with the ajax calls or loading the actual data). Rather, I’m trying to understand how to know my scroll position or to know when I’m near reaching the bottom of the data (so I can load more ahead of time).
So, How do I know when to load more data based upon scroll position?
Here is a solution, using the non-standard (but widely supported)
scrollHeightproperty:You might want to load more data before the user reaches the bottom, if so, you should use some threshold:
If you don’t want to use
scrollHeight, you have to have an inner element the height of which you can use to calculate. Perhaps wrapping thetablewith adiv, and settingoverflow: scrollon thedivinstead. See how to tell if you’re scroll to bottom for details.