【发布时间】:2009-08-31 23:50:27
【问题描述】:
给定一个实例化的 JavaScript 对象/类,我可以从该类进行 Ajax 调用,并将返回的成功函数回调到调用者的对象中吗?
目前我可以让回调返回到对象中,但是我丢失了“this”属性,这会杀死我的对象的状态
function BaseConsoleHelper()
{
this._iconIndex = 0;
}
BaseConsoleHelper.prototype = {
Dispose: function()
{
this._previousIndex = 0;
},
GetVisitConsoleIcons: function(name)
{
this._iconIndex = 500;
SampleNamespace.MyService.GetConsoleIcons(name, this.IconsGenerated);
},
IconsGenerated : function(result)
{
//I should be 500.....but I'm not, cause "this" has become something else
alert( this._iconIndex );
}
};
顺便说一句,我使用 asp.net ajax 3.5(哇,这里的继承与纯 JavaScript 没有什么不同)
【问题讨论】:
标签: asp.net javascript asp.net-ajax