Angular JS를 배우고 있고 HTTP 요청 수신에 문제가 있습니다. 어떤 이유로 (내가 불을 지르고에서 디버깅 할 때 나는 응답이 ""것을 볼 거기에 아무것도 경고.) 나는 빈 오류 응답을 얻을각도 JS - 빈 오류 응답
function countryController($scope,$http) {
delete $http.defaults.headers.common['X-Requested-With'];
$http.get("http://localhost:8080/countrybook/api/v1/countrybook")
.success(function(response) {
$scope.countries = response;
})
.error(function(response){
alert(response);
});
}
: 여기 내 코드입니다.
내 헤더는 다음과 같이 :
응답 헤더 :
Cache-Control private, must-revalidate
Content-Length 355
Content-Type application/javascript
Date Sat, 15 Nov 2014 16:53:52 GMT
Last-Modified Sat, 15 Nov 2014 16:52:06 GMT
Server WebStorm 9.0.1
요청 헤더 :
function countryController($scope,$http) {
delete $http.defaults.headers.common['X-Requested-With'];
$http.get("http://localhost:8080/countrybook/api/v1/countrybook")
.success(function(response) {
$scope.countries = response;
})
.error(function(response){
alert(response);
});
}
:
Accept */*
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Cache-Control max-age=0
Connection keep-alive
Host localhost:63342
If-Modified-Since Sat, 15 Nov 2014 16:52:06 GMT
Referer http://localhost:63342/CountryBook/index.html
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0
내가 방화범 볼 수 있다는 응답은 이것이다
Coul 뭐가 잘못 됐는지 알아내는 걸 도와 주겠니? 브라우저에서 직접 http 요청을 받으면서 위에서 언급 한 동일한 링크를 사용하면 예상 한 응답을 볼 수 있습니다. 당신의 도움을 주셔서 감사합니다! 내 일반 $에 http 패턴 백엔드을 모르고
Firefox 응답이 섞여있는 것 같습니다. 응답이 ""인 경우 알림이 올바르게 표시되는 것 같습니다. 귀하의 질문에 대한 답변이 백엔드 측면에서 발견 될 것이라고 가정합니다. – smartbart24
안녕하세요 SmartBart24. 백엔드 로그를 확인했습니다. 내 백엔드가 정확한 응답을 발송합니다. 또한 브라우저에서 직접 사용하면 동일한 링크가 제대로 작동합니다. 방화 광에서 볼 수있는 응답은 위에서 언급 한 것과 같은 각도의 JS 코드입니다. 그리고 나는 경고를 공란으로 얻는다. 나는 방화범을 끌고 응답에 시계를 추가했다. 응답이 비어 있습니다. 내가 어디로 잘못 가고 있는지 확실하지 않습니다. – takeradi
$ httpProvider.defaults.headers.common [ 'Accept'] = 'application/json, text/javascript'; $ httpProvider.defaults.headers.common [ 'Content-Type'] = 'application/json; charset = utf-8 ';'귀하의 코드 –