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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Be sure to use rawurlencode/rawurldecode to preserve plus signs -- they get turned automatically into spaces if you use normal urldecode (or rely on the automatic form decoding behavior). encodeURIComponent() is the equivalent in JavaScript. Walter On Apr 8, 2007, at 6:27 AM, 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---