Nginx允许跨域

解决方法
配置文件中加

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title></title>
    </head>
    <body>

    </body>
</html>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
    $.ajax({url:"https://item5.pasawu.top/api/Banner/index",success:function(result){
           console.log(result);
        }});
</script>>

Pasa吴PHP博客
请先登录后发表评论
  • 最新评论
  • 总共0条评论