单个codeigniter控制器上的CORS

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.

Only that controller is going to be accessed from other domains. I have tried

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');

just after opening the php code, in the constructor and even the method but nothing changes at all.

My current htaccess looks like this:

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

Adding header files to it didn't solve the problem either.

The calling ajax is:

 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){

            }


        });

The codes work very well in non-codeigniter applications. Any universal solution that can work in all browsers and hopefully, don't need .htaccess?