rules in htaccess are not working in remote server when it is moved from local

I am sending ajax request to the server. First, I send request to local server. I got following error message:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

In order to solve the issue, I added following rules to .htaccess:

<IfModule mod_headers.c>

Header always set Access-Control-Allow-Origin "*"

</IfModule>

It solved the problem. However, when I uploaded codes to server, I got previous error: "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.".

I run repair .htaccess files from admin panel, but still do not know the reason. Please, help me