Answer the question
In order to leave comments, you need to log in
How to get an object from JSON?
Good day. The task is to get an object from an external JSON file and save it to a variable:
var App = {
blockElem: undefined,
elem: undefined,
data: undefined,
init: function(str){
this.blockElem = str;
this.elem = document.getElementById(this.blockElem);
this.getData();
this.renderDefault();
this.logInfo();
},
renderDefault: function(){
this.elem.innerHTML = this.blockElem;
},
renderHead: function(){
},
getData: function(){
this.data = $.getJSON('data.json');
},
logInfo: function(){
console.log(this.data);
},
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question