Copy link to clipboard
Copied
I've been reading a lot lately about ColdFusion Ajax features and even though I learned some basics still need a few tips from you guys to learn more. That being said, I would like to output data from mysql database using cfc and ajax but do not know how to handle ajax part. More specifically need to automatically load additional data when the user scrolls to the bottom of the page. The perfect example of this is Facebook where data (more stories) are loaded every time you get to the bottom. I am not asking for the entire code but some tips (articles) on how to get started and would really appreciate your help on this one
Copy link to clipboard
Copied
There are really two parts to your question.
First, Ajax is fairly straightforward and there are lots of articles. I would say there are two ways to go about it. After making a function in a CFC you can call it either using CFAJAXPROXY or via a javascript function. The javascript code can be a little tricky however if you use jQuery that will simplify it. CFAJAXPROXY is probably the simplest, but jQuery gives you more direct control over what is going on.
Secondly, Load on scroll is not the simplest task. There maybe a premade jQuery plugin that will help you with this. Otherwise I did it by using jQuery scroll methods. You have to judge when a user has scrolled the right amount to load the next section of data, and then just modify the MySQL query to grab the next set of data.
Hope this helps a little