Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Convert javascript array to a ruby array

Reply
Thread Tools

Convert javascript array to a ruby array

 
 
David
Guest
Posts: n/a
 
      09-08-2008
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:'put',postBody:"'data='+myArray.toJSON"});

}

Thanks for any input!
 
Reply With Quote
 
 
 
 
SAM
Guest
Posts: n/a
 
      09-08-2008
David a écrit :
> 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()
> {


var myArray = [];

> for(i=1;i<22;i++){
> if (document.getElementById(i+'d').className ==


could be better with :
if (document.getElementById('d'+i).className ==
no ?

> "selected"){
> myArray.push(i);
> }
> }


alert('myArray = '+myArray.join(' - '));
alert('myArray.toJSON = '+myArray.toJSON());


> new Ajax.Request('/appointments/array/',
> {method:'put',postBody:"'data='+myArray.toJSON"});
>
> }
>
> Thanks for any input!

 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      09-09-2008
David wrote:
> Hey can anyone help me convert a javascript array into a ruby array.


If you told us what a "ruby array" is, the chances for that would increase
considerably.

> [...] 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.


Useless information, without knowing what was going to be processed where
and how.

> Im not sure what is wrong.


Neither can anyone else, unless you told us ...

> function test()
> {
> for(i=1;i<22;i++){
> if (document.getElementById(i+'d').className ==
> "selected"){
> myArray.push(i);


what `myArray' is, ...

> }
> }
>
> new Ajax.Request('/appointments/array/',
> {method:'put',postBody:"'data='+myArray.toJSON"});


what `Ajax.Request' is.

BTW: You "forgot" to declare `i' a variable.

> }
>
> Thanks for any input!


Likewise.

<http//jibbering.com/faq/>


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: convert python List to javascript array Chris Rebert Python 0 09-02-2011 05:26 PM
How to convert a ruby string into WChar string in ruby? Wu Nan Ruby 3 12-26-2007 02:36 PM
[ANN] RubyJS - Convert Ruby to Javascript Michael Neumann Ruby 8 01-15-2007 08:04 AM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
convert a C/C++ array to a Ruby array elathan@phys.uoa.gr Ruby 6 01-11-2004 08:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57