我试图通过PHP后端更新/插入MySQL数据库中的数据.我正在用AngularJS构建前端,并使用$http
服务与REST API通信.
我的设置如下所示:
I'm setting the header via the $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 Dev Console in Chrome shows me this:个
当我从POST转换为看跌期权时,我发送的是期权看涨期权,而不是看跌期权.而内容类型仅切换到content-type
.
My request payload is send as an object:
我如何正确设置我的页眉?
EDIT:
PHP后端设置了一些标题:
$e->getResponse()
->getHeaders()
->addHeaderLine('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
$e->getResponse()
->getHeaders()
->addHeaderLine('Access-Control-Allow-Origin', '*');
是不是少了什么东西?