Alternatively, use a JSON object for the parameters option of your Ajax
call. In other words instead of
var pars = "firstname=" + $F('firstname');
pars += "&lastname=" + $F('lastname');
pars += "&title=" + $F('title');
pars += "&phone=" + $F('phone');
pars += "&email=" + $F('email');
you could use:
var pars = {
firstname: $F("firstname"),
lastname: $F("lastname"),
title: $F("title"),
phone: $F("phone"),
email: $F("email"
}
Then just say { parameters: pars } as an option to your Ajax object and
you'll be good to go. I've never had a problem with encoding/decoding
of parameters using this syntax but it's happened to me a few times
using yours.
Good luck,
-- Dash --
tronen wrote:
> I have this function doing a Ajax.Request. However, when I am looking
> at the POST array that I get to my script it does not contain the +
> sign in the "phone number" that I might enter.
>
> function submitSignup() {
> var success = function(t) { submitSignupSuccess(t); }
> var failure = function(t) { submitSignupFailure(t); }
>
> var url = "signup.php?action=register";
> var pars = "firstname=" + $F('firstname');
> pars += "&lastname=" + $F('lastname');
> pars += "&title=" + $F('title');
> pars += "&phone=" + $F('phone');
> pars += "&email=" + $F('email');
>
> var req= new Ajax.Request(url, {method: 'post',
> postBody:pars, onSuccess: success, onFailure:
> failure});
>
> }
>
> function submitSignupSuccess(t) {
> //do some stuff
>
> }
>
> function submitSignupFailure(t) {
> //do some stuff
>
> }
>
> Any insights in this?
>
> /Peter
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---