understanding scope can't get variable passed from inside function

understanding scope can't get variable passed from inside function

Hi,

Trying to declare var in 'ready' function and retrieve new set value in another inner function. Will not work!!
Will not work even if var is declared outside of the 'ready' function.

Please help in getting this to work.


  1.  ===========  HTML  ===============

    <div id="who" align="center" >
       
        <h3> Whose Health log?</h3>

        <input type="radio" name="patients" id="r1" value="Polly" />Polly
        <input type="radio" name="patients" id="r2" value="Rick"  />Rick
     
    </div> <!-- id-who -->


     ============ JQUERY/JAVASCRIPT  =========

    <script type="text/javascript">
  2.                                                                       
    $(function () {  // ready function

    var patient="";                            // declaring global var

        $('input[type=radio]').click(function() { patient=$(this).val() });    // produces value

        $('#next').click(function ()  { nextRecord() });

        $('#prev').click(function ()  { prevRecord() });

        var url="healthPatientData.php";
       
        alert('patient = '+patient);    // does not show value
       
        $.post(url, {'patient': patient}, processData, "json");
           
        function processData(myData) {

     ...