Hi,
I have a general question about Web Services in MS Ajax.
The code snippet below shows a simple JavaScript class.
Type.registerNamespace("Namespace");
Namespace.Class= function(MainTagID) {
this.MainTagID = 1;
this.SomeOtherValue = "whatever";
}
Namespace.Class.prototype = {
GetTagObject: function()
{
Namespace.Class.GetTagObject(this.MainTagID, param1, param2,
param3, this._onReceiveTagObject, this.onFailedCallback);
},
// This is the callback function that
// processes the Web Service return value.
_onReceiveTagObject: function(TagObject)
{
alert(this.SomeOtherValue)
}
...
}Let's say I create a new object and call the GetTagObject method.
var x = new Namespace.Class()
x.GetTagObject();
After a succesful WebService request, onReceiveTagObject gets called which returned a TagObject from the server.
However, I have lost all information about the client side JavaScript class (alert(this.SomeOtherValue) fires an error)
Is there an elegant solution to solve this?
My ideas so far:
1) Pass all the variables that I need on a return as additional payload (a lot of work)
2) Create a global variable and pass the name of the instance as an additional parameter and call something like eval(TagObject.MyInstanceName + '.myFunction()') which is not a very elegant solution in my view.
Any thoughts on this one?
Thanks,
Andre