Hi, I have the following code for HTTP POST in my angular App. The reason I am using URL encode is to convert this into a simple HTTP POST (otherwise its converted to OPTIONS).
This code works perfectly on iOS but on Android devices, the POST is simply discarded (no error) - my server does not even receive it. Can someone help me understand why?
var req = $http({
method: 'POST',
timeout: 10000,
url: loginData.url + 'zm/index.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
},
transformRequest: function (obj) {
var str = [];
for (var p in obj)
str.push(encodeURIComponent(p) + "=" +
encodeURIComponent(obj[p]));
var foo = str.join("&");
console.log("****RETURNING " + foo);
return foo;
},
data: {
view: "request",
request: "stream",
connkey: $scope.connKey,
command: cmd,
user: loginData.username,
pass: loginData.password
}
});
req.success(function (resp) {
console.log("SUCCESS: " + JSON.stringify(resp));
var str = toast_blurb + "event:" + resp.status.event;
console.log(str);
$ionicLoading.hide();
$ionicLoading.show({
template: str,
noBackdrop: true,
duration: 2000
});
});
req.error(function (resp) {
console.log("ERROR: " + JSON.stringify(resp));
});
}