[英]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.