This is my code in sign-up.ts
let link = "http://localhost/signup.php";
this.http.post(link, signupdata)
.subscribe(data => {
console.log("Success");
},error => {
console.log("Error");
});
when I submit the form I get the following error in my console
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.
Help me in solving this.
You can try it by installing chrome extension Allow-Control-Allow-Origin: *
How it works:
Note: You have to disable this when you use other sites.
Put these lines into the top of your signup.php script:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
header('Access-Control-Allow-Credentials: true');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.