0
I am mounting a Javascript object with the following constructor:
var jsonResult = ""; // Inciei uma variável fora do escopo da Função
function criarDicionario(lang) {
this.lang = lang;
this.dicio = $.getJSON('pt-br.json').done(function(data) {
alert(data.responseJSON); /* O Alert exibe corretamente o responseJSON */
jsonResult = data.responseJSON;
});
console.log(this.dicio); // Devolve Objeto
console.log(jsonResult); // Devolve Undefined
/* Gostaria de armazenar this.dicio.responseJSON em uma variável */
this.renderMessage = function(text) {
document.write(this.dicio.responseJSON['text']);
}
}
What I would like is that variable this.dicio.responseJSON
could be stored in such a way that I could call it later in function renderMessege()
.
Possible duplicate of What is a callback?
– BrTkCa