如何在angular2

时间:2017-02-16 09:04:31

标签: angular angular2-forms

我在邮递员表格中的回复我的PHP代码如下,

   {
   "error_code": 0,
   "message": "Inserted Successfully.",
     "msg": "Inserted successfully."
  }

MY ANGULAR CODE,

   onSubmit(form:any){
 var headers = new Headers();
 headers.append('Content-Type', 'application/json');
 this.http.post('http://localhost/server/index.php/Profile/insertUser', JSON.stringify(form), { headers: headers})
     .subscribe(
        response => {
            if(response.status === 200){

            }
        }
     )
     }

但它没有得到回复,任何人都可以帮我检查响应。 错误是

Unexpected token A in JSON at position 0

1 个答案:

答案 0 :(得分:0)

检查服务器端的JSON参数。错误Unexpected token A in JSON at position 0告诉post调用中的无效JSON参数。 检查您的JSON.stringify(form) JSON值。