I want to call a JavaScript function through PHP and store the returned value in a PHP variable. How to do this?
Asked
Active
Viewed 293 times
0
-
What function? What exactly are you doing? This is possible, but there may be a better way since JavaScript is client-side and PHP is server-side. – John Kugelman Oct 31 '09 at 06:09
-
If you post what you're trying to do, we can help you find a solution. – James Skidmore Oct 31 '09 at 06:15
-
exact duplicate of http://stackoverflow.com/questions/419240/how-to-get-javascript-function-data-into-php-variable etc. – ax. Oct 31 '09 at 07:08
1 Answers
1
You can't do that - javascript being a client side technology will execute after your PHP script has already finished so there's no way to do what you are looking to accomplish.

Marek Karbarz
- 28,956
- 6
- 53
- 73
-
you can do that - for an example, see http://stackoverflow.com/questions/419240/how-to-get-javascript-function-data-into-php-variable – ax. Oct 31 '09 at 07:07
-
1technically you're not calling a javascript function from PHP, you're just using AJAX to get a PHP page - so it's going javascript -> PHP not PHP -> javascript – Marek Karbarz Oct 31 '09 at 07:14