1
angularjs의 jsonp 오류 콜백에서 응답 메시지를 가져 오려고하는데 응답 데이터가 정의되지 않았습니다. 나는 409 http 코드로 응답을 리턴한다. 브라우저에서 jsonp url을 직접 열면 "angular.callbacks._0 ({"message ":"재설정 링크가 잘못되었습니다 "})"오류 콜백에서이 메시지를받을 수 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까?angularjs에서 JSONP 오류 콜백에서 데이터를 가져 오는 방법은 무엇입니까?
// Extend angular app for api requests
app.factory('User', function($http) {
var User = function(data) {
angular.extend(this, data);
};
// Send link for password reset to entered email
User.reset_password = function() {
return $http.jsonp(jsonp_url + 'user/reset_pass?_method=post&user_key=' + user_key + '&callback=JSON_CALLBACK');
};
return User;
});
app.controller('ResetPasswordController', function ResetPasswordController($scope, User){
$scope.submit = function() {
var response = User.reset_password();
response.then(function(data){
//Success callback
}, function(data){
// Error callback
console.log(data) // Output: {config : {...}, data: undefined}
});
}
});
이것은 JSONP의 제한 사항입니다 . http://stackoverflow.com/a/1002797/62082를 참조하십시오. –