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

前端 未结 7 2072
余生分开走
余生分开走 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:17

    In Yii you simply check

        if (Yii::app()->request->isAjaxRequest)
    

    If you use jQuery or other major javascript library it works. If you do custom requests, don't forget ot set X-Requested-With HTTP header to XMLHttpRequest.

提交回复
热议问题