[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby and ajax.

music

5/24/2007 8:55:00 AM

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.
2 Answers

Paul Stickney

5/26/2007 6:05:00 PM

0

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?)

music

5/29/2007 10:01:00 AM

0

Paul Stickney wrote:
> 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?