You will not be able to handle the return value that you are returning from your asynchronous callback. You should handle the responseText
within the callback directly, or call a helper function to handle the response:
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
handleResponse(http.responseText);
}
}
function handleResponse (response) {
alert(response);
}