3
저는 AngularJS에서 매우 새로 왔으며 서버에 REST 요청을 보내기위한 지침서를 따르고 있습니다. 이것은 내 코드입니다
angular.module('myApp')
.controller('MainCtrl', ['$scope','$window','$http', function($scope,$window,$http)
{
$scope.submitForm = function() {
var url = 'http://localhost:8080/Server/config/start';
var request = $http({
method: 'POST',
url: url,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
transformRequest: function(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
return str.join('&');
},
data: {gsvalue: $scope.name}}).success(function() {});
}
}]);
제대로 서버 측에서 요청을 받았지만 응답을 얻을 수 없어 성공 함수가 호출되지 않습니다. 나는 또한 콘솔
Error: $http(...).success is not a function
및
Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
.......
Possibly unhandled rejection: {}
에 두 개의 경고를 얻을 좀 비슷한 주제를 발견하지만 난 그들과 함께 내 문제를 해결할 수 없습니다.