2012-04-02 53 views
0

我试图将[email protected]这样的电子邮件保存到模型,然后使用主干保存到服务器。 当我发送像“sdnfkjs”这样的正常单词时,它正确保存并将模型发送到服务器。 但是,当我发送“[email protected]”则说:“400错误的请求”,像这样的网址: - > ... test/contact_email/[email protected]/tid/2924 400错误的请求咖啡脚本,骨干 - - 转义'@'字符,而不是将其读为'this'

应该是什么原因呢? 感谢

+1

你是如何提出请求? URL中的特殊字符需要转义。像jQuery的东西会为你做这个。 – Thilo 2012-04-02 08:37:16

+1

工作!只是编码的电子邮件地址,我的意思是取代@与其他字符一样;并在后端进行解码。 – user1305989 2012-04-02 18:15:44

回答

2

您可能需要使用内置的Javascript编码器/解码器的使用方法:

encodeURIComponent("[email protected]") // returns "example%40gmail.com" 
decodeURIComponent("example%40gmail.com") // returns "[email protected]"