0
각도 내에서 Bing 맵 REST API를 사용하려고합니다. Fiddler는 아래의 두 요청에 대해 200 개의 응답을 표시하지만 Angular는 "No Access-Control-Allow-Origin 헤더가있는"$ hhtp와 "예기치 않은 토큰이있는"$ 요청을 보냅니다.200 응답이 반환 된 경우에도 각도 오류에서 Bing 맵 REST 사용
분명 내가 모르는 뭔가가있어 각도 전에 만있는 출처 간 요청을하려고 노력했다. 어떤 도움을 주시면 감사하겠습니다.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular-resource.js"></script>
</head>
<body ng-app="myapp">
<div ng-controller="myctrl"></div>
<script type="text/javascript">
var myapp = angular.module('myapp', ['ngResource']).config(['$httpProvider', function ($httpProvider) {
// delete header from client:
// http://stackoverflow.com/questions/17289195/angularjs-post-data-to-external-rest-api
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);
myapp.controller('myctrl', ["$scope", "$resource", "$http", function ($scope, $resource, $http) {
var t = $resource('http://dev.virtualearth.net/REST/v1/Locations?locality=Redmond&adminDistrict=WA&key=MAPKEY&o=json',
{
callback: 'JSON_CALLBACK'
}, {
jsonpquery: { method: 'JSONP', isArray: false }
});
var x = t.jsonpquery().$promise;
debugger;
x.then(function (data) {
debugger;
console.log(data);
});
$http.get('http://dev.virtualearth.net/REST/v1/Locations?locality=Redmond&adminDistrict=WA&jsonp=jsonp&key=MAPKEY')
.success(function(data) {
debugger;
})
.error(function(data, status, error, thing) {
debugger;
console.log(data);
});
}]);
</script>
</body>
</html>
당신은 비록 요청을하려면 https://www.bingmapsportal.com/에서지도 키가 필요합니다. 어떤 도움 감사합니다. 그렇지 않으면 jQuery 사용으로 넘어갑니다.