【发布时间】:2018-02-17 21:20:28
【问题描述】:
大家好,我创建了一个应用程序,使用 PHP 中的 API 和 CODEIGNITER,但我无法读取我的正文它发送的内容,因为它在其他情况下被看到,而不是通过 POST 发送数据 比如是这样的:
当我用 HTML 从 JavaScript 发送它时
user = "Ivan More Flowers"
但是当我通过 IONIC 发送它时,它会以这种方式出现
user: "Ivan More Flowers"
这已经返回给我null
我在 IONIC 3 中的代码:
//import { Component } from '@angular/core';
import { Injectable } from '@angular/core';
import { Http, Headers, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class UsuarioProvider {
api: string = 'http://localhost/xxxxxx/Welcome/'
constructor(public http: Http) {
console.log('Hello UsuarioProvider Provider');
}
verificarUsuario(usuario: string, password: string) {
let body = { usuario: usuario};
let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
return this.http.post(this.api, JSON.stringify(body), {
headers: headers,
method: "POST"
}).map(
(res: Response) => { return res.json(); }
);
}
}
BACKEND,我的代码是:
function index() {
$usuario = $this->input->post('usuario');
$password = $this->input->post('password');
echo json_encode($usuario);
}
【问题讨论】:
标签: angular codeigniter http ionic-framework ionic3