Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

How to create an endless newsfeed when scrolling down.

I am almost donw with my social network...but having some issues in creating an endless newsfeed of posts where the users can see the old posts while scrolling down

Josh Keenan
Josh Keenan
19,652 Points

What language are you looking to do this in?

as i told u i am doing everything in php

1 Answer

You'll need to use a client-side language like javascript to check on the user's scrolling. Some thing like this:

window.onscroll = function() { if(window.scrollY >= (document.body.offsetHeight - window.innerHeight)) { /* request more content probably using AJAX */ } };

I'm not sure if there's a way to do this only using PHP.

Josh Keenan
Josh Keenan
19,652 Points

AJAX will be needed if you want to do this I think, unless there is a way to do this in PHP but I have never seen something like it. Christopher is right.

good good...i did it :)

thanks for helping