Jquery编程中遇到了CORS跨域问题

Jquery编程中遇到了CORS跨域问题
想做一个无刷新导航网页,目前分支网页也是按照html的标准格式写的,内容比index.html这张网页简单。目前是如果不写 access-control-allow-origin,那么就会出现CORS跨域问题;如果写了access-control-allow-origin,那么就会直接跳转到新的网页,实现不了无刷新导航。

</head>
<body>
    <h1>History API示例</h1>
    <ul id="menu">
        <li><a href="C:\Users\DELL\.vscode\我的博客\news.html">News</a></li>
        <li><a href="C:\Users\DELL\.vscode\我的博客\about.html">About</a></li>
        <li><a href="C:\Users\DELL\.vscode\我的博客\contact.html">Contact</a></li>
    </ul>

<div id="content">
    <h2>当前内容页:测试.html</h2>    
</div>

    


<script>
           

            function getContent(url,addEntry){
                $.get(url)
                .done(function(data){
                    $('#content').html(data);
                    if(addEntry==true){
                        history.pushState(null,null,url);
                    }
                })
            }
            $(function(){
                $('#menu a').on('click',function(e){
                    e.preventDefault();
                    var href=$(this).attr('href');
                    getContent(href,true);
                    $('#menu a').removeClass('active')
                    $(this).addClass('active');
                })
            })
        
            window.addEventListener("popstate",function(e){
                getContent("C:\Users\DELL\.vscode\我的博客\测试.html",false) 

            })
            

    

</script>


</body>

是否应该把分支网页写成txt后缀的文件?内容只包括主体部分?以及跨域问题要如何解决?

后端接口设置一下跨域

这个需要你的服务器定义允许跨域。