Log in

View Full Version : Is this done in AJAX or php?



mikster
09-05-2011, 07:41 PM
Hi,

http://imgur.com/gallery when you scroll to the bottom more content is displayed without the page reloading. How is this done?? My only guess is ajax?? Can someone point me to the right direction thanks.

bluewalrus
09-05-2011, 08:12 PM
It is ajax which probably uses php as well.

This thread relates to this somewhat http://www.dynamicdrive.com/forums/showthread.php?t=64281

djr33
09-05-2011, 08:17 PM
AJAX is a method in Javascript to dynamically load a page on the server. Although that page can be just plain HTML, it is most often a serverside language (such as PHP, ASP, CGI, JSP, etc.) so that new dynamic content from the server (such as a database) can be loaded.
In other words, it's not usually "PHP or Ajax". Ajax is the method for loading something (often PHP) in the browser.

jscheuer1
09-05-2011, 08:19 PM
One could use AJAX for that. Or, since it's images, something like:

http://www.appelsiini.net/projects/lazyload

could be used.

Oddly enough, AJAX would probably be easier to make be the way it's done on that page you linked to. And from my experience in the past working with Lazy Load, probably more cross browser.

You could include some PHP, to like grab the images from a folder. But if you already know the images, no PHP would be required.

djr33
09-05-2011, 09:20 PM
Right: the reason that PHP (or another serverside language) is [probably] required for this is that Javascript won't know the paths to all of the images. That would require preloading all of that information into JS when the page originally loads, still using PHP to do it, and it would load a limited amount inefficiently: if it's too few, then you wouldn't be able to continue loading pages, but if it's too many, then that's a waste of processing and bandwidth every time the page is loaded.

The cleanest way to do this, in my opinion, would be to use Javascript to generate a standard layout and add it to the page's current HTML source. It would also use Ajax to request a list of new images (along with descriptions and whatever else is required). You would use an array of some sort, potentially XML, probably best as JSON. Then those would be inserted into that standard layout. There's no point in transferring the HTML layout every time since it never changes.