The function corresponding to the registration page cannot get the value of the text control.

Source: Internet
Author: User
The function corresponding to the registration page cannot get the value of the text control. The function corresponding to the registration page is:
$.post('{:U("Register/register")}', $('#register'), function(str) {     //  .serialize()


RegisterAction. class. php:
// Register public function register () {$ data ['U _ username'] = strtolower (I ('name', '', 'trim ')); $ data ['U _ phone'] = I ('phone', '', 'trim'); $ data ['U _ email '] = I ('email ', '', 'trim'); $ data ['U _ password'] = I ('pass'); $ data ['repassword'] = I ('rpass '); $ rpass = I ('rpass ');......

The values obtained from these variables are empty. why?

In the register template file,
if (email === 0 || phone === 0 || code === 0 || username === 0 || password === 0 || rpassword === 0) {...

The values of these email and other variables are all 0.

if (document.getElementById("email").value === 0 || document.getElementById("phone").value === 0 || document.getElementById("code").value === 0 || document.getElementById("username").value === 0 || document.getElementById("password").value === 0 || document.getElementById("rpassword").value === 0) {

In this way, the values of various text box controls are obtained.

Text box code:
 


Reply to discussion (solution)

If register is the form id
So
$. Post ('{: U ("Register/register")}', $ ('# register '). serialize (), function (str ){.......

It's a THINKPHP framework project!

If register is the form id
So
$. Post ('{: U ("Register/register")}', $ ('# register '). serialize (), function (str ){.......



Thank you for your reply! The strange thing is that you didn't execute RegisterAction. class. php's register!

Why?

Other similar ajax triggers. Why can't this AJAX be triggered? Think twice!

The above is not correct. AJAX is triggered, and this strange string is returned. I don't know where it comes from: {"info ": "\ u9a8c \ u8bc1 \ u7801 \ u8f93 \ u5165 \ u9519 \ u8bef! "," Status ": 0," url ":""}
It should return 1 or "registration failed. please try again !" That's right! Strange!

If ($ status & $ status2 & $ status1 & $ status3) {$ m-> commit (); unset ($ _ SESSION ['thirdpartyuserid']); unset ($ _ SESSION ['thrid _ party_type ']); $ _ SESSION ['uname'] = $ data ['U _ username']; die ("1") ;}else {$ m-> rollback (); die ("registration failed, please try again! ");}

Print_r (json_decode ('{"info": "\ u9a8c \ u8bc1 \ u7801 \ u8f93 \ u5165 \ u9519 \ u8bef! "," Status ": 0," url ":""}'));

StdClass Object
(
[Info] => incorrect verification code!
[Status] => 0
[Url] =>
)

You didn't follow the rules!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.