JSONP 요청으로 API에서 데이터를 가져 오려고하는데 매번 404가 발생합니다. 내 URL이 잘못되었다고 생각하지만 Chrome에서 수동으로 URL을 방문하여 원하는 응답을받을 수 있습니다. 내 $http.jsonp
은 오류 콜백에서 내 console.log
에 404 오류가 항상 표시되도록 요청합니다. JSONP 요청이 각도 앱에서 404를 제공합니다.
$scope.fetchDefaultLabel = function() {
// This code will eventually set the label to the site name when the endpoint field blurs.
// Currently not working properly.
if ($scope.endpoint) {
var baseUrl = $scope.endpoint.split('/')[2];
var siteNameUrl = 'http://' + baseUrl + '/api/sitename.json?callback=JSON_CALLBACK';
console.log(siteNameUrl);
$http.jsonp(siteNameUrl)
.success(function(data, status, headers, config) {
$scope.label = data;
})
.error(function(data, status, headers, config) {
console.log('Data: ' + data);
console.log('Status: ' + status);
console.log('Headers: ' + headers);
console.log('Config: ' + config);
});
}
};
네트워크 패널 내가 기대하는 응답 본체와 요청에 대한 200 응답을 보여 주지만, 그 어떤 이유 각도에 점점 아니에요.
이미 보셨나요? http://stackoverflow.com/questions/19916362/angularjs-how-to-make-a-jsonp-request – klode
@klode 나는 그것을 보았다. API가 JSONP 요청을 지원하지 않을 수 있습니다. 그게 가능하니? – raddevon
나는 똑같은 문제가있다. – Miraage