使用PHP通过jQuery检索设置cookie

I am trying to set a cookie with jQuery on SUCCESS and retrieve it with PHP My code looks like this:

$.ajax({
    url: "ajax.php",
    type: "POST",
    data: { 
        tid: '.$testID.',
        do:"'.$do.'"
    },
    success: function( html ) {
        $("#partBox").html( html ); 
        var hgt = Math.ceil(($("#partBox").height() - 31) / 2); 
        $.cookie("partBoxH", hgt);
    }
});

and my PHP:

isset($_COOKIE['partBoxH']) ? $_COOKIE['partBoxH'] : '50' 

it does not seem to work for some reason... Am I missing anything?

First set the cookie after that do the AJAX call, like that:

$.cookie("partBoxH", hgt);

than do AJAX call:

$.ajax({
    url: "ajax.php",
    type: "POST",
    data: { 
        tid: '<?php echo $testID;?>',
        do:"'<?php echo $do;?>'"
    },
    success: function( html ) {
        $("#partBox").html( html ); 
    }
});

Is the php code located in the file ajax.php?...
In his case you are setting up the cookie after the ajax call (on success).