Passing arguments to ruby script

G

Gale CC

Hi,

I'm using ajax with ruby for my application, and need to send an
argument to the ruby script for further action. I couldnt do it using
the command line method, since the ruby script is being called from
inside a JavaScript script. The following line of code calls the ruby
script:

xmlHttp.open("GET","ajaxhandler.rb",true)

If I do something like:
xmlHttp.open("GET","ajaxhandler.rb" + myargument,true)
then the script fails.

The PHP way to handle such cases is to add "?argument=argumentvalue"
after the file name. And then within the PHP script you can further
parse the values.

Is there anything similar in Ruby ? Or is there any other fix to this
problem ?

Thanks,
Gale
 
G

Gale CC

If you simply cannot, then raid its JS library, prototype.js, for
high-level
wrappers. There's simply no reason to call xmlHttp yourself, when
libraries
like prototype.js have taken care of all the hairy asynchronicity and
networking issues for you.

Firstly, I dont want to use Rails because I'm not writing a full fledged
web app, but rather something with a web interface and Ruby just happens
to be the scripting language.
Secondly, I guess I didnt phrase my question properly. I just want to
know a way to figure out how to "parse" and not "pass" arguments sent to
a script. I know I can send arguments using
"scriptname.rb?argument1=value1&argument2=value2", I just want to know a
way to parse those two values - argument1 and argument2 inside the
script scriptname.rb. Is there a way around ?

Thanks,
Gale
 
G

Gale CC

Gale said:
Firstly, I dont want to use Rails because I'm not writing a full fledged
web app, but rather something with a web interface and Ruby just happens
to be the scripting language.
Secondly, I guess I didnt phrase my question properly. I just want to
know a way to figure out how to "parse" and not "pass" arguments sent to
a script. I know I can send arguments using
"scriptname.rb?argument1=value1&argument2=value2", I just want to know a
way to parse those two values - argument1 and argument2 inside the
script scriptname.rb. Is there a way around ?

Thanks,
Gale

Nevermind I figured it out.
I just need to access it using a cgi object- cgi.params['argument1']
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top