I have this simple JSON
{"places" : {
"home" : {
"1": "red"
}
}}
I need to get 1
value depend on some variable which is my body class. Body class is changable. So this is my script:
(function(){
var bodyClass = $('body').attr('class');
function getPlaceValue(){
return $.getJSON('data.json', function(data) {
var placeValue;
placeValue = data.places.bodyClass.1;
return placeValue;
});
}
getPlaceValue().done(function(placeValue){
console.log(placeValue);
});
}).call(this);
I have respond that 1
value is undefined. What is wrong, is there a possible to do this?