I'm a newbie in javascript and write a little app, but I know that onload
an asynchronously function is and return not work.
Have anyone an idea?
Thanks for your help
function onDeviceReady() {
if (function1()){
if (getDBsettings()){
if (function3()){
dostuff;
}
else{
alert("");
}
}
else{
alert("");
}
}
else{
alert("");
}
}
function getDBsettings(){
var xmlhttp= new XMLHttpRequest();
xmlhttp.open("POST","http://abcdefgh.php", false);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.onload = function(){
if(xmlhttp.status == 200){
var json_string = xmlhttp.responseText;
var json = JSON.parse(json_string);
if(json.success===1){
return true;
}
else{
return false;
}
}
else if(xmlhttp.status == 404){
return false;
}
else{
return false;
}
};
xmlhttp.send();
}