Hi there,
I've got a problem that i can not get around it.

I have different objects that i'll be using and each of those objects
needs to make requests to the server to get it's data.

So let's ay in objectA i create a new variable(newB) of objectB, then
objectB will get it's data and initialize itself then if i want the new
variable to get me those data right after i issue newB.getResult.

in this example, i get the following result:
INFO: ObjectA.getObjectB: i will create a object B and call getB.
INFO: ObjectB.getB will request to get Data and parse it as JSONDoc
INFO: ObjectA.getObjectB finished, i should have data:
INFO: ObjectB.handleB data, JSON return is: [object Object]

3 AND 4 should be switched...

how do i get around this??

.......
<script>

var ObjectB =function(){
        bindMethods(this);
        this.dataB = null;
};

ObjectB.prototype.getB = function(){

        log("ObjectB.getB will request to get Data and parse it as JSONDoc");
        var rs = loadJSONDoc('/test.json');
        rs.addCallbacks(this.handleB, this.errrorB);
};

ObjectB.prototype.handleB = function(JSONData){
        this.dataB = JSONData;
        log("ObjectB.handleB data, JSON return is:",JSONData);

};
ObjectB.prototype.returnB = function(){
        return this.dataB;
};

ObjectB.prototype.errrorB = function(e){
        logFatal('Could not communicate with the server',e.message);
};

var ObjectA = function(){
        bindMethods(this);
        this.dataA = null;
};
ObjectA.prototype.getObjectB = function(){
        log('ObjectA.getObjectB: i will create a object B and call getB.');
        var someB = new ObjectB();
        someB.getB();
        var bData = someB.returnB();
        log('ObjectA.getObjectB finished, i should have data:',bData);
};

                </script>
        </head>
        <body>

                <script>

                        var someObjA = new ObjectA();

                </script>
                <input type="button" value="Issue GET Object B."
onclick="someObjA.getObjectB()">
        </body>
</html>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to