2
I can’t get the value returned from the function, what would be the reason? Someone could help me?
In my html page I have the following function:
function montarCursos(){
            var cursos = controller.getCursos();
            if(cursos != null){
                for(var i = 0; i < cursos.length; i++){
                    $("#cursos").append('<button class="ui-btn ui-corner-all" data-transition ="slide" onclick="controller.setNomeCurso("' + cursos[i].Value +'")">' + cursos[i].Name + '</button>')
                }
            }   
        }
var controller = {
getCursos: function () {
        function carregarCursos() {
            var resultado = [];
            var cursos = new cursosDao();
            resultado = cursos.getCursos();
            if (resultado.length > 0) {
                return resultado;
            } else {
                return null;
            }
        }
        loadDependence("Dao/cursosDao.js", carregarCursos);
    }
}
function loadDependence(url, callback) {
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;
    script.onreadystatechange = callback;
    script.onload = callback;
    head.appendChild(script);
}
function cursosDao() {
    this.getCursos = function() {
        var cursos = [];
        cursos.push({
            "Value" : "Anáse de Sistemas",
            "Name" : "Anáse de Sistemas"
        });
        cursos.push({
            "Value" : "Ciência da Computação",
            "Name" : "Ciência da Computação"
        });
        return cursos;
    }
}
You’d better put the code here in place of a link to an external site.
– Otávio
Edited question, excuse me...
– Jedaias Rodrigues