I tried to return value from callback to a variable but it doesn't work For example:
var events;
function getEvents(callback) {
$.ajax({
// ...
success: function(data) {
callback(data);
}
});
// return data;
}
function eventSucess(data) {
events = data;
};
getEvents(eventSucess);
console.log(events);
// Finally the value from events = nothing but If I tap events in the browser console I will have the correct value.
I want to have the value in my variable events.