jquery ajax 请求接口存在跨域。配置nginx,可以允许跨域。
配置文件中加
add_header ‘Access-Control-Allow-Origin’ ‘*’;
add_header ‘Access-Control-Allow-Credentials’ ‘true’;
add_header ‘Access-Control-Allow-Methods’ ‘GET, POST, OPTIONS’;
server {
listen 80;
root /www/projection;
index index.html index.php index.htm index.nginx-debian.html;
server_name test.com;
if (!-e $request_filename) {
rewrite /(.*)$ /index.php?$1 last;
break;
}
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}