Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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
Angularjs 拒绝连接到[Any Url],因为它违反了以下内容安全策略指令_Angularjs_Cordova_Angularjs Http - Fatal编程技术网

Angularjs 拒绝连接到[Any Url],因为它违反了以下内容安全策略指令

Angularjs 拒绝连接到[Any Url],因为它违反了以下内容安全策略指令,angularjs,cordova,angularjs-http,Angularjs,Cordova,Angularjs Http,我试图访问post方法中的数据,其名称为Login(),但当URL传输到其位置时,会生成错误 错误:-拒绝连接到 '' 因为它违反了以下内容安全策略指令: “默认src‘自我’数据:间隙:‘不安全评估’”。 请注意,“connect src”未显式设置,因此“default src”为 用作退路 我打包了“Allow-Control-Allow-Origin:*”扩展并将其安装到chrome中,但它不起作用 代码 $scope.Login = function (callback) {

我试图访问post方法中的数据,其名称为Login(),但当URL传输到其位置时,会生成错误

错误:-拒绝连接到 '' 因为它违反了以下内容安全策略指令: “默认src‘自我’数据:间隙:‘不安全评估’”。 请注意,“connect src”未显式设置,因此“default src”为 用作退路

我打包了“
Allow-Control-Allow-Origin
:*”扩展并将其安装到chrome中,但它不起作用

代码

 $scope.Login = function (callback) {
    $http({
        method: "Post",
        url: "http://smartlearner.com/SmartLearner/UserAccount/LearnerLoginByMobileApp",
        params: {
            Password: $('#Password').val(),
            Email: $('#Email').val(),
            crossDomain: true
        }
    }).success(function (data) {

        //Do Something here

    }, callback)
    .error(function (data, errorThrown) {

       //Do Something here

    }, callback);
};
您需要安装以允许Cordova应用程序中的XHR支持。没有它,您无法发出外部请求


运行:
cordova插件添加https://github.com/apache/cordova-plugin-whitelist.git

当然可以<代码>cordova插件添加https://github.com/apache/cordova-plugin-whitelist.git