如何从http.post(Angular2)调用的PHP文件中捕获回显值?

I'm calling a PHP file with the following code:

var link = 'link.php';

var data = JSON.stringify({ email: this.data.email, password: this.data.password});

let headers = new Headers();
headers.append('Content-Type', 'application/json');

this.http.post(link, data, { headers: headers }).subscribe(res => {
  alert(res);
});

I'm echoing a string from the PHP file, but nothing is being stored in res. Is there something I'm missing, or am I completely going about it the wrong way?

Thanks

查看全部
duanlu6114
duanlu6114
2016/08/25 16:10
  • angular
  • php
  • typescript
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复