Re: how i assign a js variable to a php variable
| From: | Phred White | Date: | Thu, 17 Sep 2009 22:36:35 +0000 |
| Subject: | Re: how i assign a js variable to a php variable | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298132@lists.php.net to get a copy of this message | ||
On Sep 17, 2009, at 2:43 PM, Andrea Giammarchi wrote:
However, if the goal is to pre-set something in php land so you don't have to pass it with your next page navigation, you could use ajax to to pass the value to a simple php script that in turn updates a php session variable, so that it is already set when you do your next real page load. You would still be "calling a page" technically, but your current displayed page would remain in place and php would have the value available on its next page load.I have to disagree Ash, you can pass js variable values to PHP but only through a page load. Then you could use $_REQUEST, $_POST, $_GET to retrieve it. I have done this before.And I am sure Ash does it on daily basis, the problem is the used therm: I want to *assign* ... not pass, assign! I am quite sure that is what he meant, since I cannot count people reading <?php ?> in the middle of the page thinking it can interact directly with nodes and javascript, and being "a new one", I think Ash replied in the correct way. Regards All true, and probably appropriate to clarify the relationship between php and js.