title: CORS on a single codeigniter controller
body: <p>I am literary about to bleed...I have a single controller that will accept POST request from an external domain. Once the post data arrives (usually a number or a date), it returns json data. The problem is CORS error in firefoz and chrome.</p>
  
  <p>Only that controller is going to be accessed from other domains. I have tried</p>
  
  <pre><code>header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow- Methods: POST, GET, PUT, DELETE, OPTIONS'); header('Access-Control-Allow-Headers: X-Requested-With, content-type, X-Token, x-token');
  </code></pre>
  
  <p>just after opening the php code, in the constructor and even the method but nothing changes at all.</p>
  
  <p>My current htaccess looks like this:</p>
  
  <pre><code>RewriteEngine on
  RewriteCond $1 !^(index\.php|public|\.txt)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?$1
  </code></pre>
  
  <p>Adding header files to it didn't solve the problem either.</p>
  
  <p>The calling ajax is:</p>
  
  <pre><code> var postForm = {'e':8756321}; //id
  
  
  
     $.ajax({
              type: "POST",
              url: "http://domain.com/staff/checkid", //staff is controller
  
              data: postForm,
              dataType : "json",
              cache: "false",
  
              success: function (result) {
  
  
                  alert(result[0]);
              },
              fail: function (result){
  
              }
  
  
          });
  </code></pre>
  
  <p>The codes work very well in non-codeigniter applications. Any universal solution that can work in all browsers and hopefully, don't need .htaccess?</p>