这是我在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.
帮我解决这个问题。
答案 0 :(得分:0)
答案 1 :(得分:0)
将这些行放在signup.php脚本的顶部:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
header('Access-Control-Allow-Credentials: true');