[英]HTTP post request to a php server from ionic 2 front end
这是我在sign-up.ts
代码
let link = "http://localhost/signup.php";
this.http.post(link, signupdata)
.subscribe(data => {
console.log("Success");
},error => {
console.log("Error");
});
当我提交表单时,我的控制台出现以下错误
XMLHttpRequest cannot load http://localhost/signup.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
帮助我解决这个问题。
将这些行放入signup.php脚本的顶部:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
header('Access-Control-Allow-Credentials: true');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.