Estoy desarrollando una aplicación web angular y me gustaría asignar el valor proveniente de una llamada AJAX a una variable. En realidad, probé muchas soluciones diferentes sin buenos resultados.
let a = testFunction(); testFunction(){ let b; $.ajax({...}).done(function(e) { b = e + 1 }); return b } console.log("The value of 'a' plus the value coming from the AJAX call is: " + a)Supongamos e=3, me gustaría tener este tipo de resultado en la consola:
The value of 'a' plus the value coming from the AJAX call is: 4Sé que puede ser bastante confuso, pero espero que me puedan ayudar.