Hi,
this is a very common question here ;o)
Just add ".bind(this)" to your annonymous function call.

onSuccess:
> function( transport ) {
>                 rows = $A( transport.responseJSON );
>                 rows.each( function( row, i ) { alert( row + '/' + i ) } )
>         }.bind(this)})


hf
Bastian

On Nov 17, 2007 7:13 PM, RobertG <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
>   this must be something stupid but I can't figure out how to keep
> JSON data recevied from AJAX call after the request is finished, the
> array comes out always empty. I must be doing some dump perlish
> assumption or doing something stupid
>
> var rows = [];
> document.observe( "dom:loaded", function() {
>         new Ajax.Request( '/ajaxrsp.html', { method: 'get', onSuccess:
> function( transport ) {
>                 rows = $A( transport.responseJSON );
>                 rows.each( function( row, i ) { alert( row + '/' + i ) } )
>         }})
>         alert( rows );
> }
>
> alert in the request body show the actual data but the second alert
> returns empty. Do I have to deep-clone it by hand or what? Please
> help. Thanks a lot.
>
> Robert G
> >
>



-- 
--
spread the word ... see  www.browsehappy.com ;o)

Calvin: Weekends don't count unless you spend them doing something
completely pointless.

Join the Greater IBM  Connection (http://www.xing.com/premiumgroup-6291.d26b7d)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to