Link to home
Start Free TrialLog in
Avatar of ryanjameswebb
ryanjameswebb

asked on

Dynamically Loading External PHP into a DIV using Prototype or scriptaculous

I'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.php>

</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.
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ryanjameswebb
ryanjameswebb

ASKER

ozanhazer: this code works perfectly in FireFox but for some reason doesn't work at all in IE.. Any suggestions?
My rather tongue-in-cheek suggestion is, "Don't use IE!"

What version of IE is giving you trouble?  Also, have you tested Safari or Opera?
Have tested it on IE 6 through 8.. so 6 7 and 8.  Works fine in safari and opera.

However IE is still a must where it is for a live site, and still 40% of my visitors seem to use IE.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In order to get everything to work in IE I had to use some of Rasmus's IE code.  Ozanhazer had the right answer hence the 300 points.  But i couldn't have gotten everything working without Rasmus and Ray so they each get 100.  Hope that is fair to all
It's quite fair, and thanks for the points.  Glad you're on the right track, ~Ray