$(“.common”).load(“./common.html”);
或者这样写
$(function(){ $.ajax({ url: 'common.html', dataType: 'html', success: function (res) { $(".common").html(res); }, error: function(e){ console.log(e); } }); });
有时写的html时需用到本地的文件,在chrome中不能正常运行,用开发人员工具看到是这样的一个问题。
在chrome中可以用–allow-file-access-from-files 命令来解决这个问题。右键点击chrome的快捷方式选择属性。在目标一栏中添加–allow-file-access-from-files,如图所示,注意与前面的内容要用一空格隔开。然后从这个快捷方式打开浏览器,html便可正常运行。注意,必须通过这个带有–allow-file-access-from-files命令的快捷方式打开的浏览器才行。
![[转载]--allow-file-access-from-files <wbr>命令的使用](https://app.yinxiang.com/shard/s64/res/000c91db-f1c1-4579-ac89-2ff29c962ea8.png)
![[转载]--allow-file-access-from-files <wbr>命令的使用](https://app.yinxiang.com/shard/s64/res/1f4b824c-dae8-48c4-82ef-0d3c4c38ffdd.png)