You can't return the variable from the function that creates the ajax callback since the variable won't be set yet.
The ajax function in turn has to call another callback with the returning result.
request.onreadystatechange =
function() {
if (request.readyState == 4) {
switch (request.status) {
case 200:
//here the variable should be changed
the_variable = request.responseXML;
the_callback(the_variable);