I want to send a POST
request to a remote php file from an ionic app to save base64 encoded data in the database. When i pass POST
data, I can see that the post parameter is sent, but when i print the response from the php file, it is blank.
I tried this code:
controller.js
$http.post("someurl", {data: {"data333": 'peter'}});
When I print $_POST
or $_REQUEST
from php, it is a blank array, but from my console I can see that parameters are passed with the json {data: {"data333": 'peter'}}
.
I have allowed cross domain in both client and server.
I also tried the standard ajax way:
$http.defaults.headers.post["Content-Type"] = 'application/x-www-form-urlencoded; charset=UTF-8';
$http({
method : 'POST',
url : 'someurl/',
headers: {
'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
},
data : {"key": "value"}
})
Can anyone help me pass the data?