jquery – Cant access then function after getJSON in Javascript
can someone tell why js is not going into the .then( functions?
I need funcParam getting setted after JSon stuff is ready, because otherwise, funcParam will receive values from previouse coderuns.
if (type == "config") {
getParamsByConfig().then(function(config){
markerNameByConfig = config[0].name;
markerCommentByConfig = config[0].description;
markerDurationByConfig = config[0].duration;
markerColorByConfig = config[0].color;
alert(funcParam);
funcParam = "'"+markerNameByConfig+"', '"+markerCommentByConfig+"', '"+markerDurationByConfig+"', '"+markerColorByConfig+"'";
});
}
function getParamsByConfig() {
//get all Configvalues
configurationName = document.getElementById('config').value.toString();
return $.getJSON("../savedConfigs/"+configurationName+".json").then(function(config) {
alert(config.toString());
return config;
});
}
Read more here: Source link