How do I check if the request is made via AJAX in CodeIgniter?

前端 未结 7 2034
余生分开走
余生分开走 2020-11-28 08:29

How do I check if the request is an AJAX? I am using CodeIgniter. I have a link that when it clicked, it\'ll open the pop-up dialog window this is done through ajax it reque

7条回答
  •  遥遥无期
    2020-11-28 09:09

    In Codeigniter we can use

    if(!$this->input->is_ajax_request()){ // check if request comes from an ajax
        redirect(site_url('home'),'refresh'); // if the request is not coming from an ajax redirect to home controller.
    }
    

提交回复
热议问题