[Solved] Calling a PHP function from a Javascript Function


By the time the <script> tag is executed on the client, the PHP portion of the code (which was run up on the server) is totally done with. Fin! Gone, out of memory, never to be seen or heard from again!

The very concept of calling connTest and passing in the Javascript variable sDataLoader makes no sense unless you abandon all concepts of linear time.

If you want to execute more code up on the server, you’ll need to make a new HTTP request and send in the data that is relevant. There’s many ways to do this, including AJAX, IFrames, postbacks, etc.

As to why this “worked” on another server, the obvious answer is it did not. It’s possible there just happened to be a server side variable called sDataLoader that did something that could possibly be confused with working.

6

solved Calling a PHP function from a Javascript Function