gpt4 book ai didi

javascript - 如何在 Angular js 中启用 CORS

转载 作者:行者123 更新时间:2023-12-03 10:29:50 25 4
gpt4 key购买 nike

我有一个controller.js

ListNewsCtrl.$inject = ['$http', '$scope', 'datacontext'];
function ListNewsCtrl( $http, $scope, datacontext) {
$scope.names = [];
$http.get("http://www.w3schools.com/website/Customers_JSON.php")
.success(function (response) {$scope.names = response;console.log($scope.names)});
};

我得到了我想要的数据。但是当我切换到不同的站点时,我收到以下消息:

XMLHttpRequest cannot load https://URL. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3424' is therefore not allowed access. The response had HTTP status code 404.

我尝试访问的信息不需要访问 token ?

最佳答案

我的答案的解决方案是这样的:

http://blog.novanet.no/angularjs-with-jsonp-and-how-i-get-to-work-on-time/#2

但是,我收到此错误:未捕获的语法错误:意外的标记:我遇到了小语法问题。但至少我可以看到我的数据

关于javascript - 如何在 Angular js 中启用 CORS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29263746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com