Reputation: 101
I try to post object from back_end bad always i have error 400 i don't know if the problem is in front on in back-end:
the index.html:
<div ng-controller="signupCtrl">
<form name="registrationForm">
<input type="text" name="firstName" ng-model="user.firstName" required">
<input type="text" name="lastName" ng-model="user.lastName" required">
<button type="submit" ng-disabled="registrationForm.$invalid"
ng-click="verification(registrationForm.$valid,user)">Submit</button>
</form>
<div>{{user}}</div>
</div>
the controller:
demoApp.controller('signupCtrl',function($scope,$http,$location) {
$scope.verification = function(isValid,user) {
var test=JSON.stringify(user);
window.alert(test);
$http.post('http://10.42.0.73:8080/signup',user).
success(function(respons) {
window.alert("hamdoulah")
});
$http({
method: 'POST',
url: 'http://10.42.0.73:8080/signup',
data: JSON.stringify(user),
headers: {
'Content-Type':'application/json'
},
}).
success(function (data, status, headers, config) {
window.alert("YES");
}).
error(function (data, status, headers, config) {
window.alert("NO")
});
};
});
please can you help me with this...
Upvotes: 0
Views: 393
Reputation: 406
When you receive HTTP 400 Error it basically means "Bad request". Propably it is issue with your server or data sent by you in user
variable is not being accepted by server's endpoint.
Upvotes: 1