Way to tell if a post came from an ajax call in codeigniter?
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
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) {}
But since you are using codeigniter, its better to use their input class . See how to do it below.
if($this->input->is_ajax_request()){ //Execute Your Code }