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

Reply via email to