Why $("body").data("n","123"); fails inside ajax success function ?

Why $("body").data("n","123"); fails inside ajax success function ?

Folks,
I am using .data() to store some data. It fails during my intended action. My syntax is, I believe correct because the same command/syntax works fine when it is placed elsewhere in the code. Thus, in the example below I would expect the alert to give me "123" but instead, it gives me "undefined".  If I place the store request else where (inside the GetDefaults() function but external to the $.ajax request, it works. If I place it before GetDefaults() it also works. But when executed as part of a ajax success, it fails.  Note, my recall.php does return successful (I have tested by placing another alert box in there just to be safe).

So - what gives? What am I not seeing? What am I doing wrong? Or have I discovered a bug?

All help greatly appreciated!
Thanks



function GetDefaults()
{     $.ajax({
        url:    'recall.php',
        dataType: "json",    cache:    false,
        success: function(data)
            {   
                $("body").data("n","123");
            },
    });   
    return true;
}


    $(document).ready(
        function(){
            GetDefaults();
           
            var x=$("body").data("n");
            alert(x);
    });