我从离子angular2服务向服务器发送一个简单的请求,如下所示:
login(authPayload) {
let _headers = new Headers;
_headers.append('Content-Type', 'application/json');
return this._Http.post(this.config.url + 'login', authPayload)
.map(res => res.json());
}
此外,我已从我的组件订阅此登录名
public login() {
this.auth.login(this.registerCredentials).subscribe(allowed => {
if (allowed) {
this.nav.setRoot('HomePage');
} else {
this.showError("Access Denied");
}
},
error => {
this.showError(error);
});
}
它发出OPTIONS
并且我已经在我的CodeIgniter
处理了这个并返回200,但是OPTIONS
获得200之后的角度不会继续。它没有发布数据。我的php代码如下
function __construct()
{
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
$method = $_SERVER['REQUEST_METHOD'];
parent::__construct();
if($method == "OPTIONS") {
die();
}
...................
请帮助..提前致谢