CORS header error

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

if ($_SERVER[REQUEST_METHOD] == OPTIONS) { if (isset($_SERVER[HTTP_ACCESS_CONTROL_REQUEST_METHOD]) && $_SERVER[HTTP_ACCESS_CONTROL_REQUEST_METHOD] == POST) { header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: X-Requested-With, content-type, access-control-allow-origin, access-control-allow-methods, access-control-allow-headers'); } exit;}header('Content-type: application/json');header('Access-Control-Allow-Origin: *');