Hi David,

JavaScript handles "this" differently from other languages you may be
familiar with.  It's set by the calling code; it's not in any way
intrinsic to the function itself.

Here are a couple of links; the first is a general (and I hope
thorough) explanation of what's happening and how to deal with it; the
second is a "how to" specific to Prototype (on the unofficial
Prototype & script.aculo.us wiki):


T.J. Crowder
tj / crowder software / com

On Jan 7, 4:24 am, David <da...@reflashed.com> wrote:
> I'm having a problem where I can't access variables of the main class
> from callbacks.  It seems like I should have to use a keyword like
> parent or something, but that didn't work.  Any thoughts on this?
> //Sample Code
> var Controller = Class.create({
>   initialize: function() {
>     //This variable is the problem
>     this.busy = true;
>     new Ajax.Request(this.AJAX_SUBMIT_PAGE,
>     {
>       method:'post',
>       parameters: params,
>       onSuccess: this.HandleResponse
>     });
> },
>   HandleResponse: function(transport){
>     //Returns undefined
>     alert(this.busy);
>   }
> });
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to