Could anyone tell me why the following statement does not send the post data to the designated URL? The URL is called but on the server when I print $_POST - I get an empty array. If I print the message in the console before adding it to the data - it shows the correct content.
$http.post('request-url', { 'message' : message });
I've also tried it with the data as a string (with the same outcome):
$http.post('request-url', "message=" + message);
It seems to be working when I use it in the following format:
$http({
method: 'POST',
url: 'request-url',
data: "message=" + message,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
but is there a way of doing it with the $http.post() - and do I always have to include the header in order for it to work? I believe that the above content type is specifying the format of the sent data, but can I send it as a javascript object?