我试图将值从回调返回到变量,但是它不起作用 例如:
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.
我想在变量事件中使用该值。