Angular 通过POST将参数从IONIC传递到PHP[CODEIGNITER]
大家好,我已经创建了一个应用程序,带有带有CODEIGNITER的PHP API,但我无法读取我的身体发送的内容,因为除了通过POST发送数据外,在其他情况下也可以看到它 例如: 当我用HTML从JavaScript发送它时Angular 通过POST将参数从IONIC传递到PHP[CODEIGNITER],angular,codeigniter,http,ionic-framework,ionic3,Angular,Codeigniter,Http,Ionic Framework,Ionic3,大家好,我已经创建了一个应用程序,带有带有CODEIGNITER的PHP API,但我无法读取我的身体发送的内容,因为除了通过POST发送数据外,在其他情况下也可以看到它 例如: 当我用HTML从JavaScript发送它时 user = "Ivan More Flowers" 但当我用离子发送时,它是这样的 user: "Ivan More Flowers" 这已经返回我null 我在爱奥尼亚3中的代码: 和后端,我的代码是: 您需要按如下所示进行操作。您的方法存在许多问题 api:
user = "Ivan More Flowers"
但当我用离子发送时,它是这样的
user: "Ivan More Flowers"
这已经返回我null
我在爱奥尼亚3中的代码:
和后端,我的代码是:
您需要按如下所示进行操作。您的方法存在许多问题
api: string = 'http://localhost/xxxxxx/Welcome/'
verificarUsuario(usuario: string, password: string) {
let headers = new Headers();
headers.append('content-type', 'application/json');
let body = { usuario: usuario};
let options = new RequestOptions({ headers: headers });
return this.http.post(this.api, body,options)
.map((res: Response) => { return res.json();}).
}
您需要按如下所示进行操作。您的方法上存在许多问题
api: string = 'http://localhost/xxxxxx/Welcome/'
verificarUsuario(usuario: string, password: string) {
let headers = new Headers();
headers.append('content-type', 'application/json');
let body = { usuario: usuario};
let options = new RequestOptions({ headers: headers });
return this.http.post(this.api, body,options)
.map((res: Response) => { return res.json();}).
}
您好,非常感谢您的回答,但现在我知道该方法是一个“选项”,我不知道该怎么办:c,有些没有安装“HTTP”,数据以这种方式发送给我的结果是:您好,非常感谢您的回答,但现在我知道该方法是一个“选项”,我不知道该怎么办:c,有些没有为“HTTP”安装数据以这种方式发送给我的情况如下所示:
api: string = 'http://localhost/xxxxxx/Welcome/'
verificarUsuario(usuario: string, password: string) {
let headers = new Headers();
headers.append('content-type', 'application/json');
let body = { usuario: usuario};
let options = new RequestOptions({ headers: headers });
return this.http.post(this.api, body,options)
.map((res: Response) => { return res.json();}).
}