How could I return a value in AJAX XMLHttpRequest?
This way doesn't work (I am sorry, I tried to Google, but I didn't find an answer):
shema = GetDoc("my_file.txt");
alert(shema);
function GetDoc(FileName)
{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
var allText = this.responseText;
return allText;
}
};
xhttp.open("GET", FileName, true);
xhttp.send();
}
EDIT: I didn't get the answer in How do I return the response from an asynchronous call? , which I checked before posting.