【发布时间】:2017-05-01 00:41:48
【问题描述】:
我想将我的 angular2 应用程序连接到我的 PHP 后端。理想情况下,我想这样做:
this.http.post('/users/create', {email: email, password: password});
问题是,当我这样做时,我的$_POST 在 PHP 中是空的。我必须怎么做才能完成这项工作?
【问题讨论】:
-
这不可能是唯一的解决方案吧?从 php://input 读取?我的意思是使用 jQuery,例如它适用于
$_POST和json对象 -
@DannySwekker — 默认情况下,jQuery 不会将请求格式化为 JSON。它使用 application/x-www-form-urlencoded 编码。你也应该clear up your apparent misconceptions about what JSON is。