I am trying to update / insert data into a MySQL database through a PHP server. I create Front End using AngularJS and use the $http service to communicate with the REST API.
My setup looks like this:
I set the header through $ httpProvider:
$httpProvider.defaults.withCredentials = true; $httpProvider.defaults.headers = {'Content-Type': 'application/json;charset=utf-8'};
And the POST-Call looks like this:
return $http({ url: url, method: "POST", data: campaign });
The Chrome dev console shows me this:

When I switch from POST to PUT, I send an OPTIONS call instead of PUT. And the content type only switches to content-type .
My request payload is sent as an object:

How to set the title correctly?
EDIT:
The PHP backend sets some headers:
$e->getResponse() ->getHeaders() ->addHeaderLine('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); $e->getResponse() ->getHeaders() ->addHeaderLine('Access-Control-Allow-Origin', '*');
Is something missing?
json javascript angularjs
Bastian Gruber May 15 '15 at 7:48 a.m. 2015-05-15 07:48
source share