'Way to tell if a post came from an ajax call in codeigniter?
I just started using CodeIgniter after using Zend for a while. My new site has a feature where you register through Ajax. In Zend I could use this to check if the incoming POST was through AJAX, and therefore from my site:
if(!$this->getRequest()->isXMLHttpRequest())
Is there a piece of code in CodeIgniter that does the same thing? If I don't make sure it's an AJAX call, someone could theoretically register anything they wanted by creating a form to post to my controller.
Thanks!
Solution 1:[1]
Since CodeIgniter 2.0, there is an easier way of checking for an ajax request.
Use: $this->input->is_ajax_request();
Doc: https://codeigniter.com/user_guide/libraries/input.html
Solution 2:[2]
you can check it using
$this->input->is_ajax_request();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | user3470929 |
