PDA

View Full Version : reloading part of a page



james438
12-13-2007, 02:44 PM
I know I can do this with frames, but how can I click on a link and change the content on a page to something else without reloading the links and header and such.

I think this can be done with js as well, but I am not familiar with js at all. Can this be done with CSS, html, MySQL, and/or PHP? If not I am willing to start researching js and frames some more.

boogyman
12-13-2007, 02:56 PM
It can be done with remote scripting more commonly known today in javascript by the name AJAX. What it would do would be to request something from the server and update just a portion of the page, rather then the whole page. The con with this is that it is very much like frames, and thus a user can only bookmark the initial page, so it's recommended to only use AJAX when the user would never need to bookmark a page (eg contact page)

If you use a server-side language like PHP, you would need to reload the entire page, however it gives you the added benefit that you can create template files for your header, footer, navigation/menu and include them into the page. Unlike AJAX using php includes gives the ability to bookmark individual pages.
While you are still sending a request for the templated pages upon every click, those template pages will be saved in cache, unless disabled, so the browser would not need to download those portions again.

HTML just provides the structure of a page, and cannot perform and real-time action, CSS is used for styling the layout of the page, and MySQL is used for storing data. You would need to use a server-side language like PHP/Python/Ruby or a client-side language like Javascript to perform this action.

My suggestion is to use PHP includes because it gives you the benefit of being able to bookmark individual pages, and it will keep your template files the same.

james438
12-13-2007, 03:27 PM
Thanks for the very thorough answer. I didn't know that browsers normally save the include files in the cache. I think I will stick with using includes now. It is what I am used to. Ajax files I am not familiar with, but I like the idea of bookmarking pages better anyway.

molendijk
12-13-2007, 09:03 PM
You can also do it with an iframe, like here (http://www.dynamicdrive.com/forums/showthread.php?t=27269&highlight=molendijk). But php seems most natural.

Arie Molendijk.