Convert javascript array to a ruby array

D

David

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!
 
S

SAM

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());
 
T

Thomas 'PointedEars' Lahn

David said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top