【发布时间】:2009-05-17 01:17:41
【问题描述】:
我在使用服务器回调到 JavaScript 中的对象内的 Web 方法时遇到问题...
function myObject() {
this.hello = "hello";
var id = 1;
var name;
this.findName = function() {
alert(this.hello); //Displays "hello"
myServices.getName( id, this.sayHello );
}
this.sayHello = function(name) {
alert(this.hello); //Displays null <-- This is where I'm confused...
alert(name); //Displays the name retrieved from the server
}
this.findName();
}
因此,当创建新的myObject 时,它会找到名称,然后在找到名称后调用sayHello。
服务例程工作并返回正确的名称。
问题是从服务器返回名称并调用 this.sayHello 后,它似乎不在同一个对象中(没有引用我们在查找时所在的 myObject名称)因为this.hello 给出了null...
有什么想法吗?
【问题讨论】:
标签: asp.net javascript web-services oop