How does thinkphp + jquery commit always show submitting? below is 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('.p_c').fadeOut(3000);location.href="{:U('Index/index')}";}else{$("#msg").remove();$('').addClass("notice").html(json.msg).css("color","#FF0000").appendTo('.p_c').fadeOut(3000,function(){return false;});//location.href="{:U('Login/index')}";//return false;}}});
Below is the empty php code
// Login verification 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'); // Check the 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 whether the password is correct if (! $ Admin | ($ admin ['password'])! = Md5 ($ pass) {$ array ['MSG '] = L ('login _ fail'); $ array ['success '] = 0; $ this-> ajaxReturn ($ array);} // Determine whether elseif is locked ($ user ['islock'] = 1) {$ array ['MSG '] = L ('login _ islock'); $ array ['success'] = 0; $ this-> ajaxReturn ($ array );}}
When you click "log on", verification is possible, but the user name and password always prompts "logging on ...."
Reply to discussion (solution)
Can I use the U method in js in thinkPHP ?? Location. href = "{: U ('index/index ')}";
I remember that tp3.0 is unavailable.
Can I use the U method in js in thinkPHP ?? Location. href = "{: U ('index/index ')}";
I remember that tp3.0 is unavailable.
Currently it seems usable. my TP version is 3.2.3 and no error is prompted.
Which of the following tells us that the backend cannot receive the values passed by ajax, and they are all null values.
Can I use the U method in js in thinkPHP ?? Location. href = "{: U ('index/index ')}";
I remember that tp3.0 is unavailable.
Currently it seems usable. my TP version is 3.2.3 and no error is prompted.
Try saving {: U ('index/index')} to the hidden form on the page.
Then location. href = $ ('# myvalue'). value;
Write the error function.
error: function(XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.status); alert(XMLHttpRequest.readyState); alert(textStatus); },
Write the error function.
error: function(XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.status); alert(XMLHttpRequest.readyState); alert(textStatus); },
Hello, there is no response. now the main problem is that the backend cannot receive the value passed by ajax. data: {"user": admin_name, "pwd": admin_pass, "authcode ": authcode}, which cannot be read in the controller.
1. how do you know that the data has not been passed in?
2. is the target url correct?
/Thinkphp/blog/User/Login/login ???
1. how do you know that the data has not been passed in?
2. is the target url correct?
/Thinkphp/blog/User/Login/login ???
The verification code can be verified upon submission, and the logon failure is always prompted when the password is verified.
Target url I use the U function
Is the password field in the data table post-md5 32-bit?
Is the password field in the data table post-md5 32-bit?
Yes, I submitted it in the form and tested it.
1. how do you know that the data has not been passed in?
2. is the target url correct?
/Thinkphp/blog/User/Login/login ???
My project directory is a User. do you know it has something to do with this user?
The verification code is verifiable. when the password is verified, the system always prompts logon failure.
$ User = I ('admin _ name', '', 'htmlspecialchars', 'trim ');
$ Pass = I ('pwd ','');
$ Verify = I ('authcode', '', 'htmlspecialchars', 'trim ');
Remove the success callback function first. Can the above three variables be printed in the controller ?? If not, check the js code. If yes, check the login code... You said that the verification code can be verified. An error occurred while verifying the password. Is there a problem with obtaining the password ??
1. how do you know that the data has not been passed in?
2. is the target url correct?
/Thinkphp/blog/User/Login/login ???
Check whether the requested url address is correct through the browser debug.
The addresses are all opposite. I finally re-wrote all jqeury code and controller code again, so there was no problem. I recall that the js code data: {} may also be different from the controller. the Project path is User, and I have another user in json, the two may conflict. Thank you for your help.