I need the user's data that I'm getting via ajax using json and store them in a variable so I can use it outside of ajax. The user data variable should store the data but when the stored ones are only displayed while it is inside the ajax and that is not what I want. Greetings.
var datosusuario;
function getUsuarioSesion(idusuario, url){
var data = {idusuario:idusuario};
$.ajax({
url:url,
type:'post',
data:data,
success:function(e){
datosusuario = JSON.parse(e);
/*Estando aqui se me muestran los datos*/
console.log(datosusuario);
}
});
}
/*Pero estando aca dice undefined*/
console.log(datosusuario);