Getting over the same orgin policy so that u can create an api
I开发者_运维百科 am trying to create a web application that can respond to post requests and return data based on the requests. But I tried an offline request using jquery in an offline application. But it seems to have this same origin policy issue. Is there a way to solve this?
try adding this to your code:
if (isset($_SERVER["HTTP_ORIGIN"])) {
header('Access-Control-Allow-Origin: ' . $_SERVER["HTTP_ORIGIN"]);
header('Access-Control-Allow-Methods: POST, GET');
header("Access-Control-Allow-Headers: Authorization, X-Authorization, x-requested-with");
}
Many entries on this already at stackoverflow.com ...
- Same origin policy -- JavaScript calling PHP
精彩评论