I have the following function:
var idArtigo = $(".codigo", this).text();
myJSRoutes.controllers.ArtigoDocumentoController.getArtigoByDebitoTipo(parseInt(idArtigo)).ajax({
success: function (data) {
if(data == true){
console.log("O ARTIGO_ID"+idArtigo+" tem debito manual");
artigosDebitoManual.push(parseInt(idArtigo));
}
}
});
function testeStateDebito(retorno){
var state;
$(document).ajaxStop(function() {
if(artigosDebitoManual.length > 0){
state = true;
}else{
state = false;
}
retorno(state);
});
}
How can I assign this "return" to a variable to use "outside" the ajax request?
I have this way:
testeStateDebito(function(cont) {
console.log(cont);
return cont;
});
The console.log
returns true or false, but I would like to have this state in a variable, like: var estado = 'valor retornado';
How can I resolve this?