错误提示:No Access-Control-Allow-Origin
Referrer-Policy : strict-origin-when-cross-origin
Nginx配置server {
client_max_body_size 50M;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
location / {
root /usr/local/nginx/html;
}
}
JavaScript调用
function demo() {
var url = "http://xxx.xxx.xx.xxx/webAPI/pe.php?pass=hxxxx&key=hnxhpxxxxxxx";
$.post(url, function (data) {
$("#result").html(data);
});
}
demo();