Thinkphp+jquery How the submission has been shown is being submitted.

Source: Internet
Author: User
Here's the jquery code
$.ajax ({type: "POST", url: "/thinkphp/blog/user/login/login", DataType: "JSON", data: {"User": Admin_name, "pwd": admin_ Pass, "Authcode": Authcode},beforesend:function () {$ ("). AddClass (" Loading "). HTML (" {: L (' Login_ ')} "). css (" Color "," #FF0000 "). AppendTo ('. login_btn ');},success:function (JSON) {if (json.success==1) {    $ (" #msg "). Remove (); $ ("). AddClass ("Notice_y"). HTML (json.msg). AppendTo ('. Div_c '). FadeOut (+); location.href= "{: U (' Index/index ')}";} else{$ ("#msg"). Remove (), $ ("). AddClass (" notice "). html (json.msg). CSS (" Color "," #FF0000 "). AppendTo ('. Div_c '). FadeOut (3000,function () {return false;}); /location.href= "{: U (' Login/index ')}";//return false;}});

The following is an empty PHP code
Login Verify public  function login () {    if (!is_post) {$array [' msg ']= ' page does not exist '; $array [' Success ']=0; $this Ajaxreturn ($array);} $user = i (' admin_name ', ' ', ' htmlspecialchars ', ' trim '); $pass = i (' pwd ', '); $verify = i (' Authcode ', "', ' Htmlspecialchars ', ' trim ');//Detection Verification Code if (!check_verify ($verify)) {$array [' msg ']=l (' login_vcode_error '); $array [' Success ']=0; $this->ajaxreturn ($array);} $admin = M (' admin ')->where (Array (' username ' = = $user))->find ();//dump ($admin);//Determine if the password is correct if (! $admin | | ($admin [' Password '])! = MD5 ($pass)) {$array [' msg ']=l (' login_fail '); $array [' Success ']=0; $this->ajaxreturn ($ Array);} Determine if ElseIf is locked    ($user [' Islock ']==1) {$array [' msg ']=l (' Login_islock '); $array [' Success ']=0; $this Ajaxreturn ($array);}  }

Verification is verifiable when you click Login, but the username and password is always prompt for "logging in ...."


Reply to discussion (solution)

In the thinkphp, you can be in JS with U method?? Location.href= "{: U (' Index/index ')}";
I remember that the tp3.0 version was not available.

In the thinkphp, you can be in JS with U method?? Location.href= "{: U (' Index/index ')}";
I remember that the tp3.0 version was not available.


Currently seems to be available, my TP version is 3.2.3, no hint of anything wrong

Who told you that the problem is that the background is not receiving the value of Ajax, are null values.


In the thinkphp, you can be in JS with U method?? Location.href= "{: U (' Index/index ')}";
I remember that the tp3.0 version was not available.


Currently seems to be available, my TP version is 3.2.3, no hint of anything wrong



Try to save {: U (' Index/index ')} in the page-hidden form

Then location.href=$ (' #myvalue '). Value;

Write the error function in the same place.

                    Error:function (XMLHttpRequest, Textstatus, Errorthrown) {                        alert (xmlhttprequest.status);                        alert (xmlhttprequest.readystate);                        alert (textstatus);                    },

Write the error function in the same place.

                    Error:function (XMLHttpRequest, Textstatus, Errorthrown) {                        alert (xmlhttprequest.status);                        alert (xmlhttprequest.readystate);                        alert (textstatus);                    },


Hello, plus no response, now the main problem is that the background is not receiving the value of Ajax passed, data: {"user": Admin_name, "pwd": Admin_pass, "Authcode": Authcode}, this value is not read in the controller.

1. How did you know that the data didn't pass through?
2, the target URL is written right?
/thinkphp/blog/user/login/login???

1. How did you know that the data didn't pass through?
2, the target URL is written right?
/thinkphp/blog/user/login/login???


The verification code can be verified at the time of submission and always prompt for login failure when verifying the password.
Destination URL I'm using the U function.

Is the password field in the datasheet the 32-bit after MD5?

Is the password field in the datasheet the 32-bit after MD5?



Yes, I submitted the test with my form.

1. How did you know that the data didn't pass through?
2, the target URL is written right?
/thinkphp/blog/user/login/login???


My project directory is user do not know the relationship with this user?

Verification code can be verified, to verify the password when always prompt logon failure
$user = I (' admin_name ', ' ', ' htmlspecialchars ', ' trim ');
$pass = I (' pwd ', ');
$verify = I (' Authcode ', ' ', ' htmlspecialchars ', ' trim ');
First, the success callback function is removed, the above three variable variables can be printed out in the controller?? If not, go to check the JS section of the code, if possible, check the login code ... You say the verification code can be verified, verify the password error, is not the password to obtain a problem??

1. How did you know that the data didn't pass through?
2, the target URL is written right?
/thinkphp/blog/user/login/login???

View the requested URL address correctly through the browser's debug.

The address was all right, and I finally rewrote all the Jqeury code and the controller code again, with no problems. I recalled the next, may be JS code data:{} inside also have and controller discrepancy, project path is user, I again in JSON inside another user, may be the two conflicts. Thank you for your help.

  • 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.