PHP接收JSON

I'm using knockout and this is my ajax code:

save: function() {
                $.ajax({
                    url:"http://localhost/loyalty/welcome/json/",
                    type: "post",
                    data: ko.toJSON(this),
                    contentType: "application/json",
                    success: function (result) { alert(result) }
                });
            }

Using firebug I can see that the json message is sent correctly, the problem is how to receive it on PHP, what is the name of what has been sent?

I'm using CodeIgniter

Thanks in advance for any help.

It would be in the variable $_POST['key'] where 'key' is the key values in the JSON object.

  save: function() {
            $.ajax({
                url:"http://localhost/loyalty/welcome/json/",
                type: "post",
                data: $(this).serialize()/*Where this is an instance of the form change with appropriate selector such as #loginForm*/,
                contentType: "application/json",
                success: function (result) { alert(result) }
            });
        }

Use $_POST in the php file to get the data I am assumin you are using jquery as well and $ is the jquery function. Now this data is available in the post superglobal. NB: you need not use json to send data through the ajax function. Data is passsed in a serialized array format like: field1=value1&field2=value2 etc...

If you must however use json, which frankly is unnecessary, use data:"json="+ko.toJSON(form)

and on server side data=json_decode($_POST['json']);

    **This is what exactly the way to post as json way**

//index.php
     $(document).ready(function(){
               obj = {}
               obj.name = "sam"
               obj.value = "12345"
                      $.ajax({
                               url:"json.php",
                               type: "post",
                               data :obj,
                               dataType:"json",
                               success: function (result) {
                                    alert(result.name);
                               }
                             });
            }); 

    //json.php  ,, the posted data is received as array ,, so we need to convert it as //json_encode to make as JSON again 

    <?php
    $jsonReceiveData = json_encode($_POST);
    echo $jsonReceiveData;
    ?>

The solution is to take

contentType: "application/json",

from ajax call.

=)