クラスの内部プロパティを変更する変数と関数を含むクラスをExtJsで作成しました。
私の問題は、クラスの内部プロパティを(クラスの内部関数または外部関数から)変更したいときに焦点を当てています。
クラス:
var Ws = new Ext.Class({
WsUrl: '',
WsErrorCode: 0,
WsOut: null,
CoreVersion: '',
AppName: '',
AppVersion: '',
BrowserLanguage: GetBrowserLanguage(),
BrowserUserAgent: GetBrowserLanguage(),
BrowserToken: '',
constructor: function(url) {
this.WsUrl = url;
return this;
},
SendCmd: function(CmdName) {
var WsOut;
var WsErrorCode;
//Send request
Ext.Ajax.request({
loadMask: true,
url: this.WsUrl,
params: {cmd: CmdName},
success: function(response, opts) {
WsOut = Ext.decode(response.responseText);
WsErrorCode = response.status;
},
failure: function(response, opts) {
WsOut = Ext.decode(response.responseText);
WsErrorCode = response.status;
}
});
this.WsOut = WsOut;
this.WsErrorCode = WsErrorCode;
return this;
}
});
ここでオブジェクトが作成されます。
var WsTest = new Ws('ws.php');
WsTest = WsTest.SendCmd('GetBrowserToken');
alert(WsTest.WsErrorCode); //Here, the code must return 200 but the value is 0 ... why ?
This.WsOut = WsOut
プロパティが正しく設定されない理由を知っていますか?