Q: Json object doesn't echo on php page I think I am getting close on this, but for some reason the json data doesn't print out when it gets to the php page.
Here is my form with some dummy data:
<form id="add_form" action="javascript:void(0);">
    <fieldset>
        <input type="text" value="5" name="dogs" id="dogs" />
        <input type="text" value="10" name="cats" id="cats" />
    </fieldset>
</form>

Here is the related function (runs from a button, not shown above):
function add()
{
    $.ajax({
    type: 'POST',
    cache: false,
    url: 'add.php',
    data: { json: $('#add_form').serialize() },
    success: success
    });
}

Finally the php that I can't seem to make work:
$json_object = json_decode($_POST['json']);
echo $json_object;

What I am really after is being able to get at the values for each element in the form (no matter how many form elements there are). As always, appreciate any advice you are willing to give.

A: there is no need to decode json because your form data passed to php page as "POST" type. so just do as follow.  
$json = $_POST['json'];
print_r($json);


A: Instead of,
function add()
{
    $.ajax({
    type: 'POST',
    cache: false,
    url: 'add.php',
    data: { json: $('#add_form').serialize() },
    success: success
    });
}

You have to use,
function add()
{
    var data = $('#add_form').serialize();
    $.ajax({
    type: 'POST',
    cache: false,
    url: 'add.php',
    data: data,
    success: success
    });
}

Then access like,
$_POST['dogs'];


A: If you want to send JSON, you have to create JSON first. .serialize does not return JSON, it returns a query string, as you can read in the documentation: 

The .serialize() method creates a text string in standard URL-encoded notation. It can act on a jQuery object that has selected individual form controls, such as <input>, <textarea>, and <select>. 

Maybe you want:
data: { json: JSON.stringify($('#add_form').serializeArray()) },

but that seems to be overly complicated. Just use 
data: $('#add_form').serialize(),

and access the data on the PHP side via $_POST['form_field_1'], etc.
