简体   繁体   中英

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

I have 2 HTML files

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

Here I am trying to load static page nav_bar.html into index.html

I tried one of the jquery load method - sample code of 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. I am not getting the way to resolve it. Note: Please avoid the use of iframe.

Thanks in advance.

Chrome enforces same origin policy. Read about it here.

Fetch html from server via ajax and load it as string.

Read more about it here

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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