In this example, i will show you codeigniter check request is ajax example. This tutorial will give you simple example of is ajax request check in codeigniter. this example will help you codeigniter check ajax request. you'll learn check ajax request in codeigniter. Alright, let’s dive into the steps.
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:
/**
* 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...
Do you like below Tutorials ?
- CRUD Laravel 7.x and 6.x Example
- Image Upload Laravel 7.x and 6.x Tutorial
- Laravel 7.x and 6.x Delete File from public folder example
- How to delete directory in Laravel 7.x and 6.x?
- How to create directory if not exists in Laravel 7.x and 6.x?
- Laravel 7.x and 6.x get all files in directory example
- Laravel 7.x and 6.x check file exists in folder example
- Ajax Autocomplete Textbox in Laravel 7.x and 6.x Example