Very simple task to do but never get it work.
say I have a class called track

function Track(){
this.id = 'a';
this.content = 'b';
}

Track.prototype.update(){
    this.content = 'b';
    alert(this.content) //alert1
    options.onSuccess = this.handle.bind(this);
    new Ajax.Request(url, options);
    alert(this.content); //alert3
}

Track.prototype.handler(transport){
    this.content = transport.responseText;
    alert(this.id);
    alert(this.content); //alert2
}

The overall structure is like this.
The funny thing is when executed; alert1 shows 'b', alert2 will show
the responseText, but alert3 will still be b.
The modification of this.content in the handler can't have global
effect. However, when alert this.id in the handler, you will see
this.id working. It seems that things are messed up in the scoping of
ajax request. Anyone has any clue how to work around ?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" 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/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to