简体   繁体   English

HTML +使用Jquery加载功能将一个html部分加载到另一个html页面中

[英]HTML + Load one html partial inside another html page using Jquery Load Function

I have 2 HTML files 我有2个HTML文件

File 1. index.html
File 2. nav_bar.html

Here I am trying to load static page nav_bar.html into index.html 在这里,我尝试将静态页面nav_bar.html加载到index.html

I tried one of the jquery load method - sample code of index.html. 我尝试了一种jquery load方法-index.html的示例代码。 ie. 即。

<script type="text/javascript">
    $(function() {
       $("#nav_bar").load("nav_bar.html"); 
    });
</script>

Working fine with Firefox but Chrome does not response to load this file. 在Firefox上可以正常使用,但Chrome无法响应以加载此文件。 I am not getting the way to resolve it. 我没有办法解决它。 Note: Please avoid the use of iframe. 注意:请避免使用iframe。

Thanks in advance. 提前致谢。

Chrome enforces same origin policy. Chrome执行相同的原产地政策。 Read about it here. 在这里阅读

Fetch html from server via ajax and load it as string. 通过ajax从服务器获取html并将其作为字符串加载。

Read more about it here 在这里了解更多

要为Chrome禁用同一来源策略:请使用Stackoverflow Post

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM