Maybe you should use json_decode($json, true); in case of you have a
problem with json_decode($json);

On 11 čvn, 14:17, Chris Chen <cdcc...@gmail.com> wrote:
> $json = $_POST['json'];
> $user = json_decode($json);
> echo $user['name'];
>
> 2009/6/11 Val Cartei <val.car...@gmail.com>
>
>
>
>
>
>
>
> > with data.name (data is the json object you pass to your success
> > function). Like:
>
> > success: function(data) {
> >                alert(data.name);
> >        }
>
> > Val
>
> > On Thu, Jun 11, 2009 at 12:40 PM, David .Wu<chan1...@gmail.com> wrote:
>
> > > If I send a json format to php, how to get the value from php? for
> > > example
>
> > > front page
> > > <script>
> > > var jsonStr = '{"name": "David", "age", "23"}';
> > > $.ajax({
> > >        url: 'json.php',
> > >        type: 'POST',
> > >        cache: false,
> > >        data: {json: jsonStr},
> > >        success: function(data) {
> > >                alert(data);
> > >        }
> > > });
> > > </script>
>
> > > php page
> > > <?php
> > > $json = $_POST['json'];
>
> > > // it's get {"name":"David","age": "23"}, but how to gete name?
> > > ?>
>
> > --
> > Valentina Cartei
> > Telephone Numbers:
> > University +44 (0) 1273 877560
> > Work +44 (0) 1273 206306
> > Mobile +44 (0)796 6882820
>
> --
> Chris

Reply via email to