Estou iniciando os estudos de JavaScript/ jQuery e estou com dificuldades no retorno de uma função
var numeroDePaginas = (function() {
“use strict”;
var qtd;
$.getJSON(“servlet/Paginas?uf=RJ&callback=?”, function(retorno) {
qtd = retorno.paginas;
console.log(qtd); // Primeiro Teste
});
console.log(qtd);
return qtd; // Segundo teste
});
numeroDePaginas ();
O Servlet funciona perfeito, no primeiro teste retorna 30 (valor esperado), no segundo teste retorna undefined
Alguem pode dar um help?