Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP的CORS问题-飞行前请求_Php_Angularjs_Cors - Fatal编程技术网

PHP的CORS问题-飞行前请求

PHP的CORS问题-飞行前请求,php,angularjs,cors,Php,Angularjs,Cors,我对PHP有CORS问题。我的文档中有以下代码: $http({ url: url, method: "GET", headers: { 'Authorization': 'Bearer zPwDlSp5AKv7MnZRwWyULhavD3WmTFPH', 'Content-Type': 'application/json' }, data: JSON.stringi

我对PHP有
CORS
问题。我的文档中有以下代码:

 $http({
        url: url,
        method: "GET",
        headers: {
            'Authorization': 'Bearer zPwDlSp5AKv7MnZRwWyULhavD3WmTFPH',
            'Content-Type': 'application/json'
        },
        data: JSON.stringify({'user_id': '17'})
    }).then(function(response) {
        console.log('Success!');
        console.log(response.data);
    }, function(response) {
        console.log('Failed!');
        console.log(response);
    })
以及后端中的以下php代码:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header("Access-Control-Allow-Headers: Authorization, X-Requested-With, Content-Type, Accept, Origin");
header('Access-Control-Allow-Credentials: true');
但是,标题设置正确,我得到:-

飞行前请求错误


您能发布您收到的错误吗?抱歉,这是我的第一个问题。XMLHttpRequest无法加载“url”。飞行前响应的HTTP状态代码无效,除了缺少几个方法之外,为什么在angular$HTTP内部使用stringify?“不起作用”告诉我们几乎没有什么有价值的东西。你能发布你得到的错误吗?对不起,这是我的第一个问题。XMLHttpRequest无法加载“url”。飞行前响应的HTTP状态代码无效,除了缺少几个方法之外,为什么在angular$HTTP内部使用stringify?“不起作用”告诉我们几乎没有什么价值