说我有这样的代码
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
}
Run Code Online (Sandbox Code Playgroud)
我收到了错误Uncaught TypeError: Object #<an Object> has no method 'draw'
.现在,我是第一个承认我对Javascript很新的人.我应该以另一种方式调用成员函数吗?或者我应该做一些完全不同的事情?
编辑:这是我创建对象的方式: …
我正在解决这个问题:
TSP:
Input: A matrix of distances; a budget b
Output: A tour which passes through all the cities and has length <= b,
if such a tour exists.
TSP-OPT
Input: A matrix of distances
Output: The shortest tour which passes through all the cities.
Run Code Online (Sandbox Code Playgroud)
表明如果TSP可以在多项式时间内求解,那么TSP-OPT也可以。
现在,首先要想到的是,如果我知道最佳解决方案的成本,则可以将b设置为voila。而且,您会不会知道,在我书的其他地方也包含有关此问题的提示:
我们如何找到最佳成本?容易:通过二进制搜索。
我想我可能在这里误会了很严重的事情。二进制搜索旨在找到给定项目在排序列表中的位置。那到底如何帮助我找到最佳成本?我真的很困惑。不幸的是,作者没有进一步阐述。
解决这个问题,我唯一想到的另一件事就是证明它们都可以归结为NP-complete的另一个问题,我可能最终会解决,但这仍然使我感到困惑。
我的问题正是标题中所说的。如果我想使用MicrosoftGraph与用户互动,我有几种选择:
graphClient.Users.Request.GetAsync()
graphClient.Users.Request.AddAsync()
Run Code Online (Sandbox Code Playgroud)
我想看看:
graphClient.Users.Request.UpdateAsync()
Run Code Online (Sandbox Code Playgroud)
不幸的是,我的问题是我看不到它。它在哪里?我在其他一些对象上看到UpdateAsync ...为什么不在用户上看到它?我错过了一些重要的文档吗?