Hi, It's the fisrt time that I work with javascript and that I use P.O.O. javascript. I saw some lessons on javascript, I start to understand.
You are right, my problem isn't "this". I retried, the problem is in the function "Ajax.Request". example code : url : function(object) { new Ajax.Request( object.php, { method: object.method, parameters: {url_analyse : this.value_event}, onComplete: function (xhr, json){ if (json) { var str = ''; json.each(function (item) { str += item.reponse; }); show_message(str;); } }, } ); } If the function "show_message" is in " new Ajax.Request()" , the result corresponds to the Request. But if the function "show_message" is outside "new Ajax.Request()" then the result corresponds to the previous Request. I don't understand why ? Thank. Laurent 2010/11/2 T.J. Crowder <t...@crowdersoftware.com> > Hi, > > I'm afraid your question doesn't make a lot of sense, I think a great > deal has been lost in translation. > > But `this` is special in JavaScript: It's set entirely by *how a > function is called*, not *where a function is defined*. This is > different from other languages. More here: > http://blog.niftysnippets.org/2008/04/you-must-remember-this.html > http://api.prototypejs.org/language/function/prototype/bind/ > > HTH, > -- > T.J. Crowder > Independent Software Engineer > tj / crowder software / com > www / crowder software / com > > On Nov 1, 8:14 pm, laurent barre <houpde...@gmail.com> wrote: > > Hi, > > > > I have a function Ajax.Responders , but i can't catch the paramater > "this" > > and i can't modify the value of the parameter "this". > > > > the result>one : the value is 'url' > > > > >two : equal *"no_good"* > > > > > three : undefined > > > > I try to find a solution, I think that in javascript , the transfert of a > > global variable(this) is not possible, do you have a solution ? or a > > explication ? > > > > Code > ---------------------------------------------------------------------- > > > > *this.element = 'url'; > > this message = 'no_good'; > > > > trace(this.element); > one > > > > Ajax.Responders.register({ > > onComplete: function (xhr, json){ > > if (json) { > > var str = ''; > > json.each(function (item) { > > str += item.reponse; > > }); > > this.message = str; > two > > trace(this.element); > three > > > > } > > }}); > > > > * > > Code > > ------------------------------------------------------------------------ > > > > thanks, > > > > Laurent > > -- > 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-scriptacul...@googlegroups.com. > To unsubscribe from this group, send email to > prototype-scriptaculous+unsubscr...@googlegroups.com<prototype-scriptaculous%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/prototype-scriptaculous?hl=en. > > -- 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-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.