Thinkphp and jquery

Source: Internet
Author: User
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.

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.