I am trying to request to HTTPS server via the post method in Ionic app. But every time, I am failing. I've tried with 2 ways. One way is using $http
, and the other way is using $.ajax
. But still not found the correct way. The codes are following as below.
-Using $http:
$http({
url: "https://beta.test.com/auth/authenticate/",
method: "POST",
data: {
"userName": "vv9@test.com",
"password": "vv9",
"ipAddress": "2d:5d:3s:1s:3w",
"remeberMe": true
},
headers: {
'Content-Type': 'application/json'
}
}).success(function(res) {
$scope.persons = res; // assign $scope.persons here as promise is resolved here
}).error(function(res) {
$scope.status = res;
});
-Using $.ajax:
$.ajax({
url: "https://beta.test.com/auth/authenticate/",
type: "POST",
data: {
"userName": "vv9@test.com",
"password": "vv9",
"ipAddress": "2d:5d:3s:1s:3w",
"remeberMe": true
},
headers: {
'Content-Type': 'application/json'
}
}).done(function() {
console.log('Stripe loaded');
}).fail(function() {
console.log('Stripe not loaded');
}).always(function() {
console.log('Tried to load Stripe');
});
How can solve this problem? What's wrong in the codes?