Yes, as you say, the function has already completed, and the value returned by your anonymous function just disappears.
It is possible to use a global variable and set it to the responseText, but this is of no use because you have no (reasonable) way to confirm that this data is now available. (I only mention this for the sake of completeness.)
All the processing of the responseText should occur within your onreadystatechange event. That is, where you are currently just displaying an alert. You could, if you like, pass the responseText to another helper function.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity
." Me Myself & Irene
Validate your HTML