Ok. After a bit of a side track... I figured it out.
In short:
1) Have the file you are calling with Ajax.Request build an output
that is a valid JSON string respresenting an array
2) Take the "transport.responseText" and .evalJSON it while setting
that to the array
ex:
function setArraySeqID(transport)
{
var transportResponse = transport.responseText;
arraySeqID = transportResponse.evalJSON();
}
Simple, just took a little while to my brain around creating
''text'' to
be transported via a technique like JSON then having to evaluate that
into a js object.
On Feb 14, 3:04 pm, BrentNicholas
<BrentNicho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi all,
>
> So I''m still a bit new to Prototype and get stuck here and there.
>
> I''m trying to figure out how to take anarrayI''ve declared
on page
> load, run Ajax.request agaist a template that writes out js to create
> thearray(or clear and populate it) and have that replace the
> contents of the originalarray.
>
> Code example:
>
> // on page loadarraycreated
> arraySeqID=newArray();
> arraySeqID[0]="1";
> arraySeqID[1]="17";
> arraySeqID[2]="18";
>
> // call to template to write a newarray
> function refreshListArray()
> {
> new Ajax.Request(''qryListArray.cfm,
> {
> method: ''get'',
> onComplete: replaceArraySeqID,
> onFailure: function(r) {
> throw new Error( r.statusText );
> }
> }
> );
>
> }
>
> // results of called template to replace the existingarray
> <script language="JavaScript"
type="text/javascript">
> arraySeqID=newArray();
> arraySeqID[0]="23";
> arraySeqID[1]="45";
> arraySeqID[2]="69";
> </script>
>
> So how do I make this last bit of js ''run on the page'' to
essentially
> blow out the oldarrayand make this the new one? Does this make
> sense?
>
> Thanks,
>
> BN
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---