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
Gale CC wrote:
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 ?
Briefly: Use Ruby on Rails. It hides all this wiring and patching behind
a
slick interface, so you can spend time on your actual features.
Without RoR, your question here is the moral equivalent of an Assembler
question on a C newsgroup. Don’t re-invent the wheel.
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.
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
Gale CC wrote:
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
Nevermind I figured it out.
I just need to access it using a cgi object- cgi.params[‘argument1’]