如何解析http响应获取为HTML?

时间:2017-10-25 16:29:58

标签: php json angular http

home.ts

this.LocationProvider.getSpecificLocation(districtid,head).subscribe(res=>{
  console.log(res),
  err=>{
    console.log(err)
  }
})

My response

response body 我必须解析响应以在视图中显示数据。我无法res.json()它将错误显示为ERROR SyntaxError: Unexpected token < in JSON at position 1

ws.php

public function location(){
       $this->load->model('Coolmodel','m',true);
         $retval = array();
        if($this->input->method() === 'post') {
          $obj = json_decode($this->input->raw_input_stream);

          $id = $obj->id;
          $retval['locations']=$this->m->getlocation($id);

        }
        else{
            $retval['status'] = '1';    
            $retval['district'] = $this->m->getdistrict();
        }

    header('Content-Type: application/json');
    echo json_encode($retval, JSON_UNESCAPED_UNICODE);

}

这是我的PHP代码,我应该进行任何修改吗?

0 个答案:

没有答案