1
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" of the ajax request?
Got it this way:
testeStateDebito(function(cont) {
console.log(cont);
return cont;
});
The console.log
returns me true or false, but I’d like to have that state in a variable, like: var estado = 'valor retornado';
How can I fix this?
What do you mean by making the request? I’m using $(Document). ajaxStop(Function() {...}) to manage the values I receive only at the end of all ajax requests
– Hugo Machado