Hello, I have a little problem with the escape function. Here is my code: function saveData() { new Ajax.Request("post.php", {method:"post", parameters:''message=''+escape(document.getElementById("shoutitmessage").value) } ); } If I have the escape function in my script I can''t post some characters e.g. ä,ö,ü,ß but if I don''t have this function in my code I can''t post ?,& but I can post ä,ö,ü,ß. Has anybody an idea how to solve this problem? Thank you! Gabriel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gabriel F. wrote:> new Ajax.Request("post.php", method:"post", > parameters:''message=''+escape(document.getElementById("shoutitmessage").value) > }); > > If I have the escape function in my script I can''t post some > characters e.g. ä,ö,ü,ß but if I don''t have this function in my code I > can''t post ?,& but I can post ä,ö,ü,ß. > > Has anybody an idea how to solve this problem?Just be "Prototypish": new Ajax.Request("post.php", { parameters: { message: $F(''shoutitmessage'') } }); - - "post" is the default value for "method"; - - "parameters" handles "hashes" (internally they''re anyway *always* converted to Hash); - - "$F" it''s a documented function that does exactly what you meant by document.getElementById("shoutitmessage").value - - Prototype will encode your data properly (meaning it uses "encodeURIComponent" instead of "escape"). - - "escape" returns the hexadecimal encoding of an argument in *the ISO-Latin-1 character set*. - -- Marius Feraru -----BEGIN PGP SIGNATURE----- iD8DBQFGPQd5tZHp/AYZiNkRAhZSAKDwM/pblcO6qwV/nCvjqS6nzSlZbwCfcN6v qvNHJO+YAUJAj3GH001T6NE=rKbw -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Gabriel F. wrote:> Hello, > > I have a little problem with the escape function. > Here is my code: > > function saveData() > { > new Ajax.Request("post.php", > {method:"post", > > parameters:''message=''+escape(document.getElementById("shoutitmessage").value) > } > ); > } > > If I have the escape function in my script I can''t post some > characters e.g. ä,ö,ü,ß but if I don''t have this function in my code I > can''t post ?,& but I can post ä,ö,ü,ß. > > Has anybody an idea how to solve this problem? > > Thank you! > > Gabriel >You probably need the encodeURIComponent() JavaScript function instead of escape(). See http://xkr.us/articles/javascript/encode-compare/ -- Ken Snyder --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---