EXTJS : Class > Access and modify properties of class

I created a class in ExtJs including variables and function that modifies internal properties to the class.

My problem is focused when I want to change internal properties of the class (from internal or externals functions of class).

The class:

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;
    }
});

Here the object is created:

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 ?

Do you have an idea of ​​why This.WsOut = WsOut does not set the property correctly ?

Answers


your issue is that the request is asyncronous. So by the time you assign wsOut, the request is still in progress. Add the scope to the request and set the internal attribute on the callback functions.

 Ext.Ajax.request({
            loadMask: true,
            url: this.WsUrl,
            scope:this,
            params: {cmd: CmdName},
            success: function(response, opts) {

                this.WsOut = Ext.decode(response.responseText);
                WsErrorCode = response.status;    
            },
            failure: function(response, opts) {

                this.WsOut = Ext.decode(response.responseText);
                WsErrorCode = response.status;    
            }
        });

Need Your Help

Threading Volume #9000

c# multithreading

Ok, So, I just started screwing around with threading, now it's taking a bit of time to wrap my head around the concepts so i wrote a pretty simple test to see how much faster if faster at all prin...

Informix: The meaning of dot (.)?

sql stored-procedures informix

Hey guys, I am wondering if anyone could tell me any special meaning of the dot (.) in Informix regarding expressions and etc.