So for anyone else coming here this is the working code.
class ep_List {
constructor()
{
this.urlForAjax ='';
this.dataList=[];
this.dataJson='';
this.dataParams={};
}
getData(method,params,url)
{
this.urlForAjax = url;
this.dataParams=params;
if(method=='get')
this.callGetAjax();
else
this.callPostAjax();
}
callPostAjax()
{
$.post(this.urlForAjax,this.dataParams,this.setList.bind(this));
}
callGetAjax()
{
$.get(this.urlForAjax,this.setList.bind(this));
}
setList(res)
{
this.dataList =res;
console.log({dataList:this.dataList});
}
}
class gasFilter extends ep_List {
displayList()
{
var that = this;
setTimeout(function() {
// Gotta make sure you call this.dataList
that.dataList.forEach(function(val){
console.log(val);
});
}, 3000);
}
}
var gasObj = new gasFilter();
gasObj.getData('get','','mapper/?mtc=101');
gasObj.displayList();
solved Javascript ECMA6 basic , variable is not defined in ajax