ruby and ajax.

M

music

I have a problem with a ruby script, it doesn't work if I call from a
ajax method.
The script is:

#!/usr/bin/ruby -w

require 'proxy1LDAP'
require 'cgi'

cgi = CGI.new
account = cgi.params

puts "Content-type: text/plain"
puts

acc=Proxy1LDAP.new
acc.connetti
acc.inserisci(account)
acc.disconnetti

If I call from action method of a form it works, but if I call from:

xmlHttp.open("POST", "/cgi-bin/ruby/accMail1.rb", true);
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.setRequestHeader("content-type",
"application/x-www-form-urlencoded");
xmlHttp.send(
"uid=" + escape(field['uid']) +
"&nome=" + escape(field['nome']) +
"&cognome=" + escape(field['cognome']) +
"&codice=" + escape(field['codice']) +
"&password=" + escape(field['password'])
);

passing parameters through send method.
It doesn't work.
 
P

Paul Stickney

Use firebug to inspect what is actually being transmitted and you get
a valid reply, etc. Also, check to make sure that CGI isn't masking
param varaibles sent via the QUERY_STRING since it is a POST request
(this might be the default behavior?)
 
M

music

Paul said:
Use firebug to inspect what is actually being transmitted and you get
a valid reply, etc. Also, check to make sure that CGI isn't masking
param varaibles sent via the QUERY_STRING since it is a POST request
(this might be the default behavior?)

What is firebug?
Anyway now the script works but I don't have any responseText.
Ajax function is:

......
function handleStateChange() {
if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
document.getElementById("log").innerHTML = xmlHttp.responseText;
}
}

the script is

require 'proxy1LDAP'
require 'cgi'

cgi = CGI.new
account = cgi.params

acc=Proxy1LDAP.new
acc.connetti
acc.inserisci(account)
acc.disconnetti
cgi.out("text/plain") do
"prova"
end

I expect the string "prova" as a responseText, the script works fine but
I don't have any responseText.
Is a script problem?
 

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,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top