Log in

View Full Version : loading a php file through javascript



nelis
10-10-2006, 02:19 PM
Ok I'm using a dynamic php page that loads a graphic from mysql data..
<img src="imageMeter.php">

I call that in a javascript file that puts it to a div tag

document.getElementById('element1').innerHTML = "<img src='imageMeter.php'>";

So clicking a particular javscript link displays the given graph to the element1 div.

My question is, is it possible, using a similar technique, that displays the output of a standard .php file?

Example

document.getElementById('element1').innerHTML = 'testpage.php'


where testpage.php is
<?php
echo "test string";
?>

Then clicking the link would put 'test string' into the element1 div tag...

DimX
10-10-2006, 03:04 PM
AJAX perhaps?

nelis
10-10-2006, 03:21 PM
Yea I thought of that.

I was trying to find away to so it similar to the <img> tag. I already have multiple ajax requests on the page so was trying to stay away from another one...

Was just looking for ideas..