dojo中not a function错误如何处理?
我在 dojo 中的 callChart
函数中收到not a function error
。我正在开发一个网站,它使用 excanvas 在浏览器上绘制一些图表。
在页面加载时,我进行了一次 Ajax 调用,该调用获取一些数据库值并将它们传递给 callChart:function()
,此 callChart 函数调用 excanvas 进行图表绘制。但在这里我得到了callChart is not a function
。
代码片段如下:
onload 我正在执行
drawChart : function(){
this.chart(true);
},
chart: function(flag){
dojo.xhrPost( {
url : "/charting.html",
load : function(data){
loadChart(data);
},
error : function(error){
console.error(" occured while fetch chart" );
}
} );
并且在成功回调方法中
loadChart : function(response){
this.callChart(response);
},
这是我的callChart,
callChart:function(chartData){
----
----
},
当我调用this.callChart(响应)时,我收到firebug错误“this .callChart(response) 不是函数
”。
非常感谢任何帮助、指导或建议。
I am getting not a function error
for my callChart
Function in dojo. I am developing a website, which uses excanvas to paint some charts on the browser.
On page load I am having one Ajax call which fetches some database values and passes them to callChart:function()
, this callChart function call excanvas for charting. But here I am getting callChart is not a function
.
Code snippet is like below:
onload I am having executing
drawChart : function(){
this.chart(true);
},
chart: function(flag){
dojo.xhrPost( {
url : "/charting.html",
load : function(data){
loadChart(data);
},
error : function(error){
console.error(" occured while fetch chart" );
}
} );
And in success callback method
loadChart : function(response){
this.callChart(response);
},
and this is my callChart,
callChart:function(chartData){
----
----
},
When I am calling this.callChart(response), I am getting firebug error "this.callChart(response) is not a function
" .
Any help, guidance or suggestions are highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的“this”是回调机制(dojo.Deferred)。使用 dojo.hitch 修复上下文:
Your "this" is the callback mechanism (dojo.Deferred). Use dojo.hitch to fix the context: