Have you tried binding the function for your onComplete action to the
object itself?
-- Dash --
Emmanuel wrote:
> Hello Christophe!
> You are right! It works fine when I put the alert inside the
> onComplete handler but
> What I am trying to do here is set the local variables with
> information from the Ajax request so that
> I can use it in the rest of my Ajax application. For example, in my
> HTML page I have:
> var thetest = new TestClass($('resultDiv'));
> alert(thetest.test);
>
> But thetest.test = 0 and not what is supposed to be there.
>
> Thanks for your help.
> Emmanuel
>
> On Apr 16, 11:16 pm, Christophe Porteneuve <[EMAIL PROTECTED]> wrote:
>
>> Hey Emmanuel,
>>
>> Emmanuel a écrit :
>>
>>
>>> initialize: function(resultDiv) {
>>> this.output = resultDiv; // Div to output current
>>> this.test = 0;
>>> searchAjax(0,100);
>>> alert(this.test);
>>> this.output is a HTMLDivElement and works fine but the alert after
>>> searchAjax() does not change from 0.
>>>
>> Your AJAX request is, as it should be, asynchronous. When you alert,
>> your onComplete handler hasn't triggered yet. Put your alert in the
>> handler, after setting this.test...
>>
>> Also, if you intend to manipulate this as a number, explicitely parse
>> your text in the handler:
>>
>> this.test = parseInt(originalRequest.responseText, 10);
>>
>> 'HTH
>>
>> --
>> Christophe Porteneuve a.k.a. TDD
>> "[They] did not know it was impossible, so they did it." --Mark Twain
>> Email: [EMAIL PROTECTED]
>>
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---