Codeigniter Check Request is Ajax Example

Codeigniter Check Request is Ajax Example

In this post we will give you information about Codeigniter Check Request is Ajax Example. Hear we will give you detail about Codeigniter Check Request is Ajax ExampleAnd how to use it also give you demo for it if it is necessary.

Sometimes, we need to check request is ajax or not in codeigniter 3 application. If you want to call same method but if request is ajax then you perform different, then you can do by using $this->input object.

In Codeigniter 3 $this->input object provide is_ajax_request() method to check request is ajax or not, In following example you can see how it’s works.

You can check see bellow controller method example so you can learn how to use is_ajax_request() and determine request is from ajax or not.

Example:

Also see:Codeigniter 3 create zip file and download example

/**

* Get All Data from this method.

*

* @return Response

*/

public function ajaxRequestPost()

{

if ($this->input->is_ajax_request()) {

$data = array(

'title' => $this->input->post('title'),

'description' => $this->input->post('description')

);

$this->db->insert('items', $data);

echo 'Added successfully.';

}else{

echo 'You can not access';

}

}

I hope it can help you…

Hope this code and post will helped you for implement Codeigniter Check Request is Ajax Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

72  +    =  75

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US