Good practices with $ .get of jquery

1

I think it's not recommended to $.get within $.get .

But then what would be the best practice for this code below:

var valorSalario = getSalarioAtual(location.state);

$.getJSON('https://geoip-db.com/json/geoip.php?jsonp=?').done (function(location) {

    if (salarioNacional(location.state)) {
        $("#salarioatual").html("Salário Mínimo Nacional <br/> R$" + this.valorSalario);
    } else {
        $("#salarioatual").html("Salário do seu estado (" + location.state + "): <br/> R$ 880.00");
    }
});

function getSalarioAtual(estado) {
    var estado = getSiglaEstado(estado);
    var salario = "";
    $.get('/salarios-estado/' + estado).done(function(response){
       salario = response.salario;
       return salario;
    });
}

What would be the best implementation for this solution? Thanks in advance.

    
asked by anonymous 09.01.2017 / 18:50

0 answers