Thinkphp and jquery thinkphp jQuery
The page code is:
Jquery event code:
$ ("# Ulogin "). click (function () {$. ajax ({url :". /index. php/User/logincheck ", type:" POST ", data: {email: $ (" # email "). val (), pwd: $ ("# pwd "). val ()}, // dataType: 'text', // timeout: 1000, error: function () {alert ('request error'); return false ;}, success: function(data={}('.emailmsg'}.html (data); // return false ;}});});
The logincheck method is as follows:
Public function logincheck (){
$ Email = $ _ POST ['email '];
$ Pwd = md5 ($ _ POST ['pwd']);
$ User = M ('user ');
$ List = $ user-> where ('email = $ email ')-> find ();
If (empty ($ list )){
Echo 'this user does not exist ';
Exit;
}
$ List = $ user-> where ('email = $ email and pwd = $ pwd')-> find ();
If (empty ($ list )){
Echo 'incorrect password ';
Exit;
}
}
Because the _ empty () method is set in the User module, the echo content in the _ empty () method is always displayed after each click. Under the guidance of a Great God!
Reply to discussion (solution)
Try action = ""
Try action = ""
Still not good
Write your url in ajax into an absolute path,
If it doesn't work any more, that's really not enough.
Why is an empty operation? What do you think about LZ?
Can you execute your logincheck method?
Nice, good.
That should be an action problem. you can change it to an absolute path or use: U ("***") to generate a path.
And finally solved the problem. I don't know if the mcleed method works, but I just changed the original url: "./index. php/User/logincheck" to the method name logincheck.