$scope.submitNewUser = function() {
$http({
method: 'POST',
url: 'api/user/signup',
data: {'user': $scope.user},
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
}).success(function(data, status, headers, config) {
console.log('hello');
alert('boo');
});
}
我有上面的内容,当它运行POST时起作用,但是我无法使该.success()
部分起作用,没有回调,console.log()
并且alert()
不触发。
谢谢
尝试添加错误处理程序
console.log("calling http;")
$http({
method: 'POST',
url: 'api/user/signup',
data: {'user': $scope.user},
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
}).success(function(data, status, headers, config) {
console.log('success', data, status);
}).error(function(data, status, headers, config) {
console.log('error', data, status);
}).catch(function(error){
console.log('catch', error);
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句