1. // 指定允许其他域名访问
    2. $http = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '*';
    3. header("Access-Control-Allow-Origin: {$http}");
    4. // 响应类型
    5. header("Access-Control-Allow-Methods: GET, POST");
    6. // 设置是否允许发送 cookies
    7. header("Access-Control-Allow-Credentials: true");
    8. // 传递json参数,需要另外配置这个
    9. header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, x-file-name");