PDA

View Full Version : Dynamic page loader - help please



Anavrinman
01-10-2007, 06:53 PM
Attempting to integrate a dynamic loader into an existing page. When a link is clicked on the sidebar, I would like load content from an include file. The closes thing I've got to that is here:


<head>
<script language="Javascript">
function dynamicTest()
{
test.innerHTML = 'Test Successful';
}
</script>
</head>
<body>
<table border="1" width="100&#37;" height="250">
<tr>
<td width="50%">
<a href="javascript: dynamicTest()">testlink</a>
</td>
<td>
<span id="test">test undergoing</span>
</td>
</tr>
</table>
</body>



I just want to take the contents of a .inc file and dump it straight into the span section instead of just a string with a few tags, while only refreshing that part of the page.

I have very limited knowledge of javascript, but I'm pretty good with php, html, and CSS.

jscheuer1
01-10-2007, 07:25 PM
Ajax is the way to go with this if you want it just as you say. There are less glamorous and perhaps better ways to accomplish the same effect though, depending upon just what the requirements are. One idea that comes to mind is replacing your span with an iframe and simply target it with links to your external pages. In any case, you will probably want to investigate what Ajax can do in this regard so, see:

http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

to get an idea of its power and:

http://www.dynamicdrive.com/dynamicindex17/indexb.html

for a listing of scripts using Ajax and other approaches that may work out for you.

One big draw back with Ajax is that any script that needs to run against the newly loaded content, if it requires initialization, needs extra code to get it to work, if it can be made to work at all.

Anavrinman
01-10-2007, 08:11 PM
That's exactly what I want. Well done and thank you very much.