简体   繁体   中英

How to use jQuery to send an email address to a Rails 3.2 controller?

How can I send an email address to a Rails controller, as a param, via jQuery, to check whether it already is registered (as part of validation for a registration form)? When I try to parameterize it with jQuery, a . remains in the parameter and Rails truncates the parameter.

I wrote a simple function to substitute in a pattern that I then replace in the controller, but I can't shake the feeling that I'm doing this the wrong way. Is there a way to encrypt the email before sending it as a parameter and then decrypt it in the controller so that I can use it in a query?

Basically, I'm trying to do some simple pre-validation so that if a user attempts to register using an email that already is registered that they will receiving a warning before submitting the form, with a link to recover their password.

Just use JSON. And you will can send/receive not only email, but another fields and error messages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM