global variables in jquery functions

global variables in jquery functions

Hello experts,
I cannot findout how I can write to global variables in a a JQUERY function.
In the following script code you will understand my problem.
I appreciate your help.
 <script type="text/javascript">

function checkusername (username ) {
$.post("http://example.com/index.php", {action: 5, username: username }, function(xml) {
result = $("apot", xml).text();               //<-- this variable is not global... why ??
message = $("message", xml).text();  //<-- this variable is not global... why ??
alert(message);                                //<--here variables are shown ok
alert(result);
});
alert(message);                             //<--here variable is NULL !!
alert(result);                                 //<--here variable is NULL !!
}
</sctipt>