我们对angular js很陌生。Angular JS中的Http Post请求
我们尝试使用http请求$http.get
它工作正常。但在后期要求它是创建一个问题,它涉及到成功和显示错误的参数错误代码103.
我们已经尝试了使用$.ajax({}),
的AJAX请求,它工作正常。
我也粘贴我的代码。
任何人都可以帮助我们吗?
mainApp.controller('registrationCtrl', function($scope, $location, $http) {
$scope.registration = function() {
console.log("registration called");
var ws_url = "http://apparelinindia.com/selfiestandoff/WebServices/register";
var request = $http({
method: "post",
url: ws_url,
data: {
user_email: $scope.email,
user_password: $scope.password
},
dataType: 'json',
headers: {
'Content-Type': 'application/json'
}
});
request.success(function(data) {
console.log("Success" + data);
});
request.error(function(error) {
console.log("Success" + JSON.stringify(error));
});
};
});
尝试用'method:“POST”'而不是? –
并移除'dataType:'json'' –