obter valores retornados de jquery get?

Eu estou fazendo chamadas jquery para obter e getJSON, mas não é possível acessar valores retornados fora da função de retorno de chamada. Como posso acessar os dados retornados?

        var firstid;
        var nextid;

    $.get(callUrl, function(data) {  // call to add node
         var n = data.indexOf("id-");
         var m = data.indexOf("id-");
         firstid = data.substr(n+3,m - (n+3));
         nextid = data.substr(m+3);

             alert("firstid:" + firstid);  // returns correct value
    });

        alert("firstid:" + firstid);  // returns undefined for firstid

Como posso ficar em primeiro lugar fora da função?

questionAnswers(3)

yourAnswerToTheQuestion