duanlu6114 2016-08-25 08:10
浏览 42
已采纳

如何从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

  • 写回答

1条回答 默认 最新

  • duanfang7270 2016-08-25 10:07
    关注

    Solved it. Needed to use

    res.text()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部