I found out why my Flag displays Undefined. It is simply that to make a alert (flagQuery) a boolean does not function.
I combine my code with that of Jan Turon, and this is achieved
function getFlagValue() {
var xmlHttp = new HmlHttpRequest();
xmlHttp.onload = function() {
if (xmlHttp.status==200) yourCustomHandler(xmlHttp.responseText);
};
xmlHttp.open("GET","getAmazonResult.php",true);
xmlHttp.send();
}
function yourCustomHandler(response) {
flagQuery = response;
alert(flagQuery);
}
flagQuery = getFlagValue();
if (flagQuery = true) {
alert ("Flag = TRUE");
}
else {
alert ("Flag = FALSE");
}
And now I see if the flag is true or false