I have a Javascript function that saves the value from checked input from a div in an array. And I want to pass this array to PHP. Is it possible? And if it is, how can I do?
-
4Use jquery ajax to pass a js variable to phpManish Jangir– Manish Jangir2013年05月20日 14:00:19 +00:00Commented May 20, 2013 at 14:00
1 Answer 1
You cannot pass variable values from the current page javascript to the current page PHP code since PHP runs in the server and it cannot know what is going on on the client side.
You may use different methods to get a response from the server using javascript variables, such as AJAX or dynamic server calls. Here's an example how to do it.
Sign up to request clarification or add additional context in comments.
2 Comments
Lucas Bastos
I will pass the array on a submit
Yosra MH
actually it's possible if he uses stringify() then json_decode() in php, but with a button or something otherwise it's not possible for dynamic variables
default