Re: Passing information across pages (please ignore previous message)
| From: | Ian | Date: | Thu, 12 Mar 2015 16:56:05 +0000 |
| Subject: | Re: Passing information across pages (please ignore previous message) | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324636@lists.php.net to get a copy of this message | ||
On 12/03/2015 15:48, Tiago Hori wrote:
<snip>
>
> However, I have not been able to read $_POST['variable'] from within the
> php page parent.page.php. It seems to me that since the code was evaluated
> after the HTTP request I am doing something wrong where the AJAX request is
> not causing the code to be evaluated again an thus something like
>
> if (isset ($_POST['variable'])) {
> $array = json_decode($_POST['variable'];
> print_r $array;
> }
>
> does not work. I have tried many forums out there, but could not solve it.
> If anybody has any suggestion or even suggested reading, that would be
> awesome.
>
> Jeffy,
>
> I have a safari account so I will look at book!
Hi,
Try looking at the contents of this:
file_get_contents('php://input');
This stackoverflow post explains why this is best for accepting JSON
from an AJAX call:
http://stackoverflow.com/questions/8893574/php-php-input-vs-post
I use this in my JSON api without problems.
Regards
Ian
--