and PHP on the server
. As Spookster has already said above, when PHP is done with processing a file, it sends the output as a HTTP response back to the client. So generally, these two technologies can't be interoperable, since they don't run in the same environment.
var testImg = new Image();
testImg.src = "http://adomain.com/test.php";
This will run the script on the server, but you don't get any output aside from image information back to the client.
With a load of DHTML and a small PHP backend you can achieve something called Remote Scripting. Heres a good resource
that contains detailed info about how to use this method.
For your script, it's purpose is not quite clear to me. I would favor a different approach that involves a refresh of the page, so when you click the button a new page gets loaded with the appropriate new output derived from the PHP function.
Hope that cleared things up.