Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,437 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,437 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