【发布时间】:2016-04-24 20:30:04
【问题描述】:
我尝试使用 Angular2 发送带有 FormData 的 post 请求。但是我的网络服务器什么也没有,给我发回错误代码 500。 我使用 PostMan util(GoogleChrome 插件)检查了请求。我发现 只有当我什么都不发送时,我才能达到 500。
let Form = new FormData();
Form.append("username", this.username);
Form.append("password", this.password);
let headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
this.http.post("/ajax/rest_login",
Form,
{headers: headers})
.map((res: Response) => res.json())
.subscribe(
res => console.log(res.text()),
err => console.log(err),
() => console.log('done'));
我做错了什么?也许您知道发布 FormData 的更好方法
【问题讨论】: