assigning results of $.post to a variable

assigning results of $.post to a variable

Hi,
I'm trying to put the result of a $.post request into a variable.
I've tried a few different ways, and none seem to work. I've tried
working with the xmlhttprequest object that $.post returns:
function mytest()
{
    var mydate = new XMLHttpRequest();
    mydate = $.post("/calendar/calendarajax.php", {mycommand:
"geteventdates", month: ym}, function(data){
            assigndays(data);
            }, "text");
    alert("mydate is " + mydate.responseText);
//all that assigndays does is alert(data) just to make sure I have real data.
}
If I just do alert(mydate) the alert box does at least show that
mydate is an XMLHttpRequest object, I just can't seem to get its
responseText.
I've tried:
function mytest()
{
    var mydate;
     $.post("/calendar/calendarajax.php", {mycommand: "geteventdates",
month: ym}, function(data){
            mydate = data;
            }, "text");
    alert("mydate is " + mydate);
}
and
<script>
var mydate;
function mytest()
{
     $.post("/calendar/calendarajax.php", {mycommand: "geteventdates",
month: ym}, function(data){
            mydate = data;
            }, "text");
    alert("mydate is " + mydate);
}
</script>
In theory, because I've scoped mydate using var, the mydate inside the
function should refer to the mydate that was locally scoped to mytest
or it should use the global variable in the second example.
Any ideas on where I'm messing up?
Thanks,
Bob
--