I am beginner programming with Angularjs and I want to make post request to my server. On the server side I'am waiting data with key value pair. I would like to know how to add the key and value in the HTTP.post.
Additional info: XAMP & Using CodeIgniter for the API.
This is what I have for the controller.
// calling our submit function.
$scope.submitForm = function() {
// Posting data to php file
var data = ({
'username': $scope.username,
'password': $scope.password,
'email': $scope.email,
'fName': $scope.firstName,
'lName': $scope.lastName,
'gender': $scope.gender
});
var config = {
headers : {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
$http.post('http://IP/URL/ ', data, config)
.success(function (data, status, headers, config) {
$scope.PostDataResponse = data;
})
.error(function (data, status, header, config) {
$scope.ResponseDetails = "Data: " + data +
"<hr />status: " + status +
"<hr />headers: " + header +
"<hr />config: " + config;
});
};
When I submit the data, this is what I get.
CONSOLE ERROR : https://i.stack.imgur.com/Qh8Ci.jpg
Network Preview information : "https://i.stack.imgur.com/oKtM4.jpg