Cross-Origin Request Blocked

Hi all,
I want to call an API from an apache server via an ajax but I have the following error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://x.x.x.x/api/method/myapi.install_site. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I tried add these line in my nginx.conf add_header Access-Control-Allow-Origin http://site_names
but it does not work every time!
any suggestion plz?

Refer this link to setup nginx Allow-Control-Allow-Origin correctly

Thanks @revant_one
I solved it