Check for Ajax request in CodeIgniter

Check for Ajax request in CodeIgniter::

To check Ajax Request in CodeIgniter, we will use CodeIgniter Output Class Method class is_ajax_request() , this function checks if the HTTP_X_REQUESTED_WITH server header has been set, if set response will be true otherwise false means it will returns a boolean response

You can use $this->input->is_ajax_request() from the input class.

if (!$this->input->is_ajax_request()) {
   exit('No direct script access allowed');
}else{
   echo "ajax request";
}

source:
https://codeigniter.com/user_guide/libraries/input.html

Please follow and like us:
0

Validation Rules for Email CodeIgniter version 3.17

I am used to CodeIgniter .

I just started to working in CodeIgniter 3.17, and reached to validation rules.

I notice that xss_clean is now gone from the validation class, so what rules should I use in the validation of email ?

$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');

For More Visit Codeigniter website :

https://www.codeigniter.com/userguide3/libraries/form_validation.html

Please follow and like us:
0