I don't realy understand why my variable is undefined This is my code:
Calendar = function() {
this.data;
this.init = function(path, callback){
$.ajax({
url:path,
type:'GET',
success:function(data){
this.data = data;
console.log(this.data);
callback();
}
})
}
this.create = function(){
this.generateYear();
}
this.generateYear = function(){
console.log(this.data);
}
}
And I use it like this:
$(document).ready(function(){
var calendar = new Calendar();
calendar.init(path,function(){
calendar.create();
});
});
So the first console.log is good but the second is undefined, I don't understand why because he is called after.
Thanks for your help