On 8 Sep 2008, at 22:54, David wrote:

>
> Sorry, that ajax.request method should be a put, so:
>
> new Ajax.Request('/appointments/array/',
> {method:'post',postBody:"'data='+myArray.toJSON"});
>
If you're just posting json then you shouldn't that data= (and you  
look like you're writing a link_to_remote :with option - right now  
you're posting the string "'data='+myArray.toJSON")

something like

postBody: Object.toJSON(myArray)

is more like it. You might also need to set the content-type header  
appropriately.

Fred

> On Sep 8, 2:52 pm, David <[EMAIL PROTECTED]> wrote:
>> Hey can anyone help me convert a javascript array into a ruby array.
>> Ive been struggling with this since friday to no avail.  This is the
>> function with the ajax.request call that is supposed to convert the
>> array using JSON, but I keep getting a 422(Unprocessable Entity)
>> error.  Im not sure what is wrong.
>>
>>         function test()
>>         {
>>                 for(i=1;i<22;i++){
>>                     if (document.getElementById(i+'d').className ==
>> "selected"){
>>                         myArray.push(i);
>>                     }
>>                 }
>>
>>  new Ajax.Request('/appointments/array/',
>> {method:'get',postBody:"'data='+myArray.toJSON"});
>>
>>          }
>>
>> Thanks for any input!
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to