var responseText = undefined;
xhr.onreadystatechange = function() {
responseText = xhr.responseText;
console.log( responseText ) // значение xhr.responseText
}
console.log(responseText); //undefined