CI Framework, the method of judging the Post,ajax,get request

Source: Internet
Author: User

All we have to do is build our own wheels. Here's a look at how to define these methods of judging requests. Actually, it's very simple.

First open the constants.php, which is a file that defines the constants. Then add these lines of code to the file.

1234 //定义请求数据的方法define(‘IS_POST‘,strtolower($_SERVER["REQUEST_METHOD"]) == ‘post‘);//判断是否是post方法define(‘IS_GET‘,strtolower($_SERVER["REQUEST_METHOD"]) == ‘get‘);//判断是否是get方法define(‘IS_AJAX‘,isset($_SERVER[‘HTTP_X_REQUESTED_WITH‘]) && strtolower($_SERVER[‘HTTP_X_REQUESTED_WITH‘]) == ‘xmlhttprequest‘);//判断是否是ajax请求

These methods can then be called in the controller file.

CI Framework, the method of judging the Post,ajax,get request

Related Article

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.