Check http://www.prototypejs.org
Example:
Main Topics
Browse All TopicsI'm sure this is an easy question to answer for the right person.
What I want to do is use prototype and scriptaculous to dynamically load an external PHP file into a div.
To be as percise as possible:
I have an index.php file that has a php include contained inside a div.. something like:
<div id="container" style="width="300px;"
<? include:videos_1_2_and_3.p
</div>
So this php file would get the 3 most recent videos from the MYSQL database. (Don't worry about this I already have it coded)
Now I also have another php file called
"videos_4_5_and_6.php"
What I want to do is create a link that says "more videos" or "next page" and when it is clicked on it loads videos_4_5_and_6.php where videos_1_2_and_3.php is (IE in the "container" div).
HOWEVER... THIS IS IMPORTANT!!!!!
It must load dynamically... So if I wanted to have 10 pages each containing 3 videos, it should only load those when the more videos button is clicked.
To be clear... I know how to do this by hiding divs or using tabs... but I need the content to load dynamically. I can't have 10 pages of 3 videos (or 30 videos) loading at the same time it will slow performance.
THE QUESTION:
How would I code this. So that when a link is clicked on:
like <a href="javascript: load:videos_4_5_and_6.php inside div:container>MORE VIDEOS</a> would work??
Also I must be able to use PHP files because they are the ones calling on the database.
Thanks so much for the input.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Check http://www.prototypejs.org
Example:
Good - at least it is consistent in that all of IE has trouble. Notice that the "Rasmus" example treats IE differently from other browsers when it creates the request object. You might want to look through the JS and be sure that you're hitting the ActiveXObject instead of the XMLHttpRequest when you use IE.
Business Accounts
Answer for Membership
by: Ray_PaseurPosted on 2009-04-11 at 11:21:15ID: 24122928
There may be a strategic question at the root of this issue, and that goes to the difference between server-side and client-side scripting. PHP is on the server side, JS is on the client side.
hp>
When you have a construct like this:
<div id="container" style="width:300px;"
<? include:videos_1_2_and_3.p
</div>
The PHP will get executed on the server at page load time and whatever it generates will appear inside the "container" DIV. So if you use JS to go into the DOM and change the contents of the "container" DIV to something new, all that will happen is that the new information will be placed in the DIV on the client end of things. It will not be parsed on the server as PHP, because there has not been another page load.
To make what you want to happen, you need to have a back-end PHP script that generates HTML (and JS - any client side stuff you want, including CSS, etc.). This back-end script creates the contents you want to put into the "container" DIV and sends it to a listener on the client machine. The listener puts the new information into the "container" DIV, and the updated page appears in the browser window.
I cannot give you a scriptaculous or prototype example, but I can give you a very simple teaching script that shows how AJAX works. It is signed "Rasmus" which makes me think it may be from "Lerdorf" of PHP fame. Can't remember where I got it, but it is elegant in its simplicity and shows the foundation of AJAX in a way that makes the client/server relationship easy to understand. It's not "light reading" but if you give yourself the time to work through it carefully you will be wa-a-ay ahead on this project.
Hope this helps, ~Ray
Select allOpen in new window