What you get while trying $json['name'] ??

Why don't you try getJSON instead of calling usual ajax call ??

Regards,

Anish**

On Jun 11, 4: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?
> ?>

Reply via email to