473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert javascript array to a ruby array

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(Unprocessab le Entity)
error. Im not sure what is wrong.

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

new Ajax.Request('/appointments/array/',
{method:'put',p ostBody:"'data= '+myArray.toJSO N"});

}

Thanks for any input!
Sep 8 '08 #1
2 4500
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(Unprocessab le Entity)
error. Im not sure what is wrong.

function test()
{
var myArray = [];
for(i=1;i<22;i+ +){
if (document.getEl ementById(i+'d' ).className ==
could be better with :
if (document.getEl ementById('d'+i ).className ==
no ?
"selected") {
myArray.push(i) ;
}
}
alert('myArray = '+myArray.join( ' - '));
alert('myArray. toJSON = '+myArray.toJSO N());

new Ajax.Request('/appointments/array/',
{method:'put',p ostBody:"'data= '+myArray.toJSO N"});

}

Thanks for any input!
Sep 8 '08 #2
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(Unprocessab le 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.getEl ementById(i+'d' ).className ==
"selected") {
myArray.push(i) ;
what `myArray' is, ...
}
}

new Ajax.Request('/appointments/array/',
{method:'put',p ostBody:"'data= '+myArray.toJSO N"});
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
Sep 9 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11043
by: Graham Nicholls | last post by:
Hi, I'm trying to size a jpeg file. The file size is held in a short (2 byte integer) at a certain offset. Once I've found these two bytes (they're in MSB,LSB order), I need to convert them to an integer - now I know that in C I'd just cast a pointer to the offset to a short, and that python doesn't cast, so how can I extract the value from a stream of bytes. I've looked at python.org/Doc/current (I'm using 2.3b1), but can't find...
5
18029
by: Andrew V. Romero | last post by:
At work we have an excel file that contains the list of medications and their corresponding strengths. I would like to save the excel file as a text list and paste this list into a javascript function and have JS put this into an array. Then JS would use this array to create a selection list which displays only the names of the drugs. When the user selections one of the drugs, another selection list will be loaded with the avaiable...
4
9669
by: D Newsham | last post by:
Hi, This javascript creates a table that has a header and side column that do not move while scrolling through the table. I need to convert this to vb script. Can anybody help, or do you have code in vb (asp) that would do the same thing? <html> <head> <title>Scrolling Grid Demo</title>
9
36830
by: mprocopio | last post by:
Fellow JavaScripters, I am looking for code or implementation ideas for converting an integer variable to a four-byte array. I'm porting some of my code from C#, where I make use of their BitConverter utility class, but am still feeling my way around a bit here with JavaScript. The idea is that each of the four bytes that comprise an integer (I presume numeric types in JavaScript are/can be made four bytes?) are extracted, and then...
10
11156
by: thinktwice | last post by:
in my script file , i need call a method of a atl com module(implemented in vc++), which returan an safearray. i don't know how to convert it into array in jscript. i have tried serveral ways to get each item but failed at last. could anyone help me?
21
6056
by: petermichaux | last post by:
Hi, I've been asking questions about library design over the last week and would like to get feedback on my overall idea for a JavaScript GUI library. I need a nice GUI library so there is a good chance I will write this as I need new widgets. I haven't found anything like this and I'm surprised/disapointed this doesn't already exist. My library prototype works nicely. I think parts of these ideas are not commonly used for JavaScript...
2
6015
by: MidnightSun | last post by:
I am wondering if it is possible to set embedded ruby variables in javascript. I've tried but to no avail. I'm thinking the javascript block won't recognize the <% %> erb tags. What I want to do is basically call a javascript function from an onclick="setField('first_name')" function setField(name) { <% fieldName = name %> } I don't think it's possible, because you are trying to put a javascript variable (name) into ruby, which I...
3
4180
by: Robert | last post by:
Hi, I'm interested in two applications for javascript. A profiler and a minimizer. I found several, but I am hoping to hear with which applications some of you guys have a good experience. I prefer open source projects. The minimizer should make the javascript small. Not just removing white-space and comments, but also make object names very small. This will probably obfuscate things, but the goal does not have to be
2
6876
by: phil.swenson | last post by:
I'm using Prototype.js and would like to convert the contents of an HTML table to JSON. Converting to an array first is fine too. Any thoughts on this? I haven't seen anyone do anything this.... thanks phil
0
9628
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10289
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8952
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.