0

I want to call a JavaScript function through PHP and store the returned value in a PHP variable. How to do this?

3
  • 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. Commented Oct 31, 2009 at 6:09
  • If you post what you're trying to do, we can help you find a solution. Commented Oct 31, 2009 at 6:15
  • exact duplicate of stackoverflow.com/questions/419240/… etc. Commented Oct 31, 2009 at 7:08

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

you can do that - for an example, see stackoverflow.com/questions/419240/…
technically 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.