title: How do I check if the request is made via AJAX in CodeIgniter?
body: <p>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 requests to a controller name <code>login_window()</code>.</p>
  
  <h3>CodeIgniter</h3>
  
  <pre><code>//Here is the controller name:
  function login_window(){
      // request via ajax
      $this-&gt;load-&gt;view("login_window");
  }
  </code></pre>
  
  <h3>jQuery</h3>
  
  <pre><code>//here is the jquery code:
  //I am using a jquery plugin FACEBOX
  
  $('a[rel*=dialog]').facebox();
  
  &lt;a href="http://localhost/codeigniter/login_window" rel="dialog"&gt;Login&lt;/a&gt;
  </code></pre>
  
  <p>I want to check if it is an AJAX request and if not, i will redirect them to homepage. so there's no way they can access the page that is intended only for ajax requests.</p>