Please refer the below example code
var report = {
chartTypes : null,
init: function () {
this.getChartTypes(function(data){
this.chartTypes = data;
});
},
getChartTypes: function(callback) {
$.ajax({
data:'',
url:'',
success:function(response){
chartTypes = JSON.parse(response);
callback(chartTypes);
}
});
},
getToolbar:function() {
this.chartTypes --------------- NULL
}
}
getChartTypes
function load different chart types via AJAX. Therefore i put it as a callback function. Data is received successfully. But when i use this.chartTypes
in a different function like getToolbar
it says this.chartTypes
is null
. Even i have initialized the same in the starting. May be scope issue. Please advise.