Tutorial, thinkphp, jquery, ajax Form Verification

Source: Internet
Author: User
After entering the mailbox in the email input box, you can pass the mailbox information to the PHP file through the JS file to determine that database operations are always wrong. If there is no database operation, that's right. I don't know why.




After entering the mailbox in the email input box, you can pass the mailbox information to the PHP file through the JS file to determine that database operations are always wrong. If there is no database operation, that's right. I don't know why.

Reply content:




After entering the mailbox in the email input box, you can pass the mailbox information to the PHP file through the JS file to determine that database operations are always wrong. If there is no database operation, that's right. I don't know why.

1. Use ajaxReturn instead of echo
2. "true" and "false" must be returned in string format"
3. The result returned by ajax isString, You cannot use if to directly determine, but should use = to determine, otherwise it will always be true if (response), so it will always return the existing

======================================
Modify answer
First, you must have a full understanding of the mvc model to use thinkphp correctly.
1. The logic of thinkphp is/controller/method,
Assume that your module name is Index (this should be the case from your project directory)


  where($where)->find()){            $this->ajaxReturn(true);        }else{            $this->ajaxReturn(false);        }    }}

Then the post code should be written in this way, and the location should be in the view folder of thinkphp.

$.post("/Login/verify",{loginEmail:loginEmail}, function(response){    ...}

Return results using ajaxReturn

Replace false and true with 'false' and 'true '.

$. Post (url, data, function, 'job ')

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.