说我有这样的代码
function Chart(start,end,controller,method,chart) { console.log('Chart constructor called'); this.start = start; this.end = end; this.controller = controller; this.method = method; this.chart = chart; this.options = {}; } Chart.prototype.update = function() { console.log('update ' + new Date().getTime()); $.getJSON('index.PHP',{ controller: this.controller,method: this.method,START: this.start,END: this.end },function(json) { this.draw(json); }); //<-- Problem right here! } Chart.prototype.draw = function(json) { //lots of code here }
我收到错误Uncaught TypeError:Object#< an Object>没有方法’画’.现在,我是第一个承认我对Javascript很新的人.我应该以另一种方式调用成员函数吗?或者我应该做一些完全不同的事情?
编辑:这是我创建对象的方式:
chartObj = new Chart(开始,结束,’OBF.RootCauses’,’ajaxRootCauses’,图表);