【发布时间】:2018-04-17 11:48:29
【问题描述】:
我有一个用户表单。我需要将用户详细信息发送到后端。于是我尝试如下图:
this.http.post("http://localhost/angular5/user-add.php", this.myform.value).subscribe(
data => {
console.log(res)
}
)
我的后端是PHP,设置CORS如下图:
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization')
如果我运行此代码,我会收到以下错误:
ERROR Object { headers: Object, status: 200, statusText: "OK", url: "http://localhost/angular5/user-add.…", ok: false, name: "HttpErrorResponse", message: "Http failure during parsing for htt…", error: Object } core.js:1665:5
非常感谢任何帮助。提前致谢。
【问题讨论】:
标签: angular angular5 angular4-forms angular4-httpclient